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

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 
主站蜘蛛池模板: 信宜市| 大埔区| 密云县| 吉木乃县| 池州市| 中江县| 兴山县| 三门峡市| 东丰县| 长海县| 长宁区| 台中市| 西吉县| 会东县| 万年县| 称多县| 称多县| 延津县| 台北县| 盐城市| 达日县| 苏尼特左旗| 乌拉特前旗| 廉江市| 元朗区| 化德县| 夏邑县| 江川县| 安吉县| 江永县| 益阳市| 南漳县| 英山县| 株洲市| 资中县| 嘉鱼县| 鹤峰县| 南雄市| 精河县| 乌兰察布市| 安溪县|