- 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.
- The Supervised Learning Workshop
- Java程序設(shè)計(jì)與開(kāi)發(fā)
- Android開(kāi)發(fā)精要
- Python Tools for Visual Studio
- NumPy Essentials
- Quarkus實(shí)踐指南:構(gòu)建新一代的Kubernetes原生Java微服務(wù)
- FFmpeg入門詳解:音視頻原理及應(yīng)用
- iOS應(yīng)用逆向工程(第2版)
- Android Native Development Kit Cookbook
- Integrating Facebook iOS SDK with Your Application
- Webpack實(shí)戰(zhàn):入門、進(jìn)階與調(diào)優(yōu)(第2版)
- Mastering Concurrency Programming with Java 9(Second Edition)
- Visual Basic語(yǔ)言程序設(shè)計(jì)基礎(chǔ)(第3版)
- 3D Printing Designs:The Sun Puzzle
- 和孩子一起學(xué)編程:用Scratch玩Minecraft我的世界