为了账号安全,请及时绑定邮箱和手机立即绑定

Java 泛型中的类型检查优点是如何体现的?

Java 泛型中的类型检查优点是如何体现的?

米脂 2018-08-16 10:09:48
使用泛型代码要比非泛型代码更有优势,下面是 java 官方教程对泛型其中一个优点的介绍:“Stronger type checks at compile time.A Java compiler applies strong type checking to generic code and issues errors if the code violates type safety. Fixing compile-time errors is easier than fixing runtime errors, which can be difficult to find.”我希望知道的是:1、在使用泛型时能在编译时被检测出的问题,在未使用泛型时是怎样的情况?即怎样才会出现这类上文中最后一句提到的不是更容易解决的运行时错误?(希望以代码举例)2、Java 如何提供这种编译时的强类型检查(第一句)。如能解决,十分感谢!
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 566 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信