- Java 11 and 12:New Features
- Mala Gupta
- 168字
- 2021-07-02 12:27:01
Non-denotable types
Java types that you can use in a program, like int, Byte, Comparable, or String, are called denotable types. The types used by a compiler internally, like the subclass of an anonymous class, which you can't write in your program, are called non-denotable types.
Up until now, type inference with variables seemed quite easy to implement—just get the information about the values passed to a method and returned from a method, and infer the type. However, it isn't as simple as that when it comes to inference with non-denotable types—null types, intersection types, anonymous class types, and capture types.
For example, consider the following code and think about the type of the inferred variables:
// inferred type java.util.ImmutableCollections$ListN var a = List.of(1, "2", new StringBuilder());
var b = List.of(new ArrayList<String>(), LocalTime.now());
Type of variable a and b isn't a type that you would have read before. But that doesn't stop them from being inferred. The compiler infers them to a non-denotable type.
- Cocos2d-x游戲開發:手把手教你Lua語言的編程方法
- Apache Hive Essentials
- Getting Started with Gulp
- 編程菜鳥學Python數據分析
- Extreme C
- Learning Node.js for .NET Developers
- Arduino Wearable Projects
- Python+Office:輕松實現Python辦公自動化
- 數字媒體技術概論
- Spring Data JPA從入門到精通
- Java高手是怎樣煉成的:原理、方法與實踐
- IBM RUP參考與認證指南
- Java EE程序設計與開發實踐教程
- 絕密原型檔案:看看專業產品經理的原型是什么樣
- 深度學習:基于Python語言和TensorFlow平臺(視頻講解版)