官术网_书友最值得收藏!

Type inference in Java 5

Generics introduced a type system to enable the developers to abstract over types. It restricted a class, interface, or method to working with instances of specified types, providing compile type safety. Generics were defined to add compile type safety to the Collections framework. Generics enable programs to detect certain bugs during compilation, so they can't creep into the runtime code. 

Java used type inference for generic method type arguments in Java 5. Consider the following code:

List<Integer> myListOfIntegers = Collections.<Integer>emptyList(); // 1

Instead of the preceding code, you could use the following code:

 List<Integer> myListOfIntegers = Collections.emptyList(); // 1 
主站蜘蛛池模板: 明溪县| 夏邑县| 久治县| 文山县| 丹巴县| 浮梁县| 沙洋县| 卫辉市| 广饶县| 东山县| 霞浦县| 龙海市| 静安区| 铁岭市| 维西| 新源县| 贞丰县| 抚顺县| 额尔古纳市| 阿克| 浠水县| 黄平县| 阳原县| 瑞金市| 兴海县| 万载县| 镇远县| 咸阳市| 江阴市| 宁海县| 宁蒗| 富锦市| 龙泉市| 荣成市| 临沭县| 通城县| 竹溪县| 白玉县| 伊川县| 庐江县| 泰来县|