- 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
推薦閱讀
- scikit-learn Cookbook
- Developing Middleware in Java EE 8
- 我的第一本算法書
- Learning ASP.NET Core 2.0
- Hadoop+Spark大數據分析實戰
- 第一行代碼 C語言(視頻講解版)
- 0 bug:C/C++商用工程之道
- MINECRAFT編程:使用Python語言玩轉我的世界
- SQL Server 2016 從入門到實戰(視頻教學版)
- App Inventor少兒趣味編程動手做
- Xamarin Blueprints
- Python應用與實戰
- Drupal 8 Development Cookbook(Second Edition)
- 3D Printing Designs:The Sun Puzzle
- Android技術內幕(系統卷)