java.lang.Void
is analogous to java.lang.Integer
. is Integer
A-a-boxing values of the primitive type. is int
A-a-on-the- Void
boxing values of the Primitive type void
.
"But wait, void
doesn ' t has any possible values!"
right! That's what makes java.lang.Void
"uninstantiable".:)
It's a nice feature of the Java type system, every primitive type has a boxed equivalent. int
Integer
has, long
have Long
, has ... and byte
Byte
void
Void
has. It would be weird and asymmetrical if Void
didn ' t exist.
"So what's the difference between and java.lang.Void
void
?"
Easy. is void
a primitive type. Void
is a reference type that inherits from Object
. They ' re similar in that neither of them have any possible values; But nevertheless they is the very different types, from the type system's point of view.
"But I don ' t has any with for in Void
my programs."
and I don ' t has any with the in GarbageCollectorMXBean
mine. Some features don ' t have non-obscure uses. That ' s okay.
The only point Void
Void.TYPE
was to hold and which is the sort of void.class
. If you had a reflective reference to a method, then returns void
, and you get the its return type, it ' ll return Void.TYPE
.
Java.lang.Void and Void