In Java, there have always existed primitive types and references, but not value types.
One of the goals of Project Valhalla is to explore and incubate feature candidates such as value types .
I would like to know if null
can be assigned to a value type variable, or if a value type variable can be compared to null
.
If not, I would also like to know why.
From here: https://wiki.openjdk.java.net/display/valhalla/Minimal+Value+Types
Value types are "immutable, identity-agnostic, non-nullable, non-synchronizable, final"
So no, it can't be null
Value type variable is value
, null
is absense of any value. So null
and value types are incompatible by definition.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.