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

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 
主站蜘蛛池模板: 县级市| 吴堡县| 本溪市| 宁都县| 宁安市| 长武县| 泰宁县| 五原县| 高要市| 石楼县| 天等县| 乌拉特前旗| 伊金霍洛旗| 班戈县| 卢湾区| 郸城县| 肃宁县| 衡阳市| 久治县| 东宁县| 德安县| 田林县| 乌兰县| 霍城县| 铁岭市| 南陵县| 永修县| 海兴县| 深水埗区| 上饶县| 泽普县| 都匀市| 金川县| 遵义县| 托克逊县| 察雅县| 磐安县| 苏尼特右旗| 安塞县| 徐闻县| 荣成市|