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

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 
主站蜘蛛池模板: 白朗县| 黔西| 资阳市| 嘉峪关市| 大荔县| 海南省| 唐海县| 汉源县| 东源县| 咸阳市| 老河口市| 溧水县| 丰原市| 平江县| 忻州市| 东阳市| 西昌市| 定州市| 城固县| 景宁| 东乡县| 广南县| 荃湾区| 阿拉善盟| 渝中区| 当雄县| 台湾省| 页游| 霍林郭勒市| 吉水县| 祁阳县| 开平市| 芦山县| 安新县| 通道| 都安| 留坝县| 湖口县| 东阳市| 博乐市| 中山市|