- 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.
- 機(jī)器學(xué)習(xí)系統(tǒng):設(shè)計(jì)和實(shí)現(xiàn)
- PHP基礎(chǔ)案例教程
- Java Web開發(fā)之道
- Reactive Programming with Swift
- Object-Oriented JavaScript(Second Edition)
- MongoDB,Express,Angular,and Node.js Fundamentals
- Mastering Unity 2D Game Development(Second Edition)
- HTML5+CSS3+jQuery Mobile APP與移動(dòng)網(wǎng)站設(shè)計(jì)從入門到精通
- 從程序員角度學(xué)習(xí)數(shù)據(jù)庫(kù)技術(shù)(藍(lán)橋杯軟件大賽培訓(xùn)教材-Java方向)
- App Inventor 2 Essentials
- Node.js區(qū)塊鏈開發(fā)
- ABAQUS6.14中文版有限元分析與實(shí)例詳解
- 從零開始學(xué)UI設(shè)計(jì)·基礎(chǔ)篇
- 大話程序員:從入門到優(yōu)秀全攻略
- 軟件測(cè)試項(xiàng)目實(shí)戰(zhàn)之功能測(cè)試篇