- 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
推薦閱讀
- Docker技術入門與實戰(第3版)
- AWS Serverless架構:使用AWS從傳統部署方式向Serverless架構遷移
- 神經網絡編程實戰:Java語言實現(原書第2版)
- Web全棧工程師的自我修養
- 零基礎學Java(第4版)
- Python機器學習實戰
- Mastering JavaScript Design Patterns(Second Edition)
- Java編程從入門到精通
- 創意UI Photoshop玩轉移動UI設計
- Scala Functional Programming Patterns
- MySQL 8從零開始學(視頻教學版)
- 數據科學中的實用統計學(第2版)
- 和孩子一起學編程:用Scratch玩Minecraft我的世界
- HTML5 Canvas核心技術:圖形、動畫與游戲開發
- Instant SQL Server Analysis Services 2012 Cube Security