- Java 11 and 12:New Features
- Mala Gupta
- 105字
- 2021-07-02 12:27:01
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
推薦閱讀
- Cocos2D-X權威指南(第2版)
- JavaScript:Functional Programming for JavaScript Developers
- Mastering Articulate Storyline
- Oracle Exadata專家手冊
- C++面向對象程序設計習題解答與上機指導(第三版)
- Android傳感器開發與智能設備案例實戰
- Hands-On GUI Programming with C++ and Qt5
- Clojure for Java Developers
- UML2面向對象分析與設計(第2版)
- Managing Microsoft Hybrid Clouds
- H5+移動營銷設計寶典
- Java EE架構設計與開發實踐
- Flutter從0基礎到App上線
- Building Scalable Apps with Redis and Node.js
- Head First Go語言程序設計