I didn\'t even know this was doable, but I saw while perusing some code online a method with a signature like this:
public List read( ... )
>
List
is weird. It can only have null
elements, since you can't create an object of type Void
. I don't think there is a practical use for such a thing.
Void
is part of java.lang
. It's not a special keyword or anything. It's a "pseudo-type" (according to the docs) used to as a place-holder to represent the Class
object corresponding to void
, as in Class
. From the docs for Class:
The primitive Java types (
boolean
,byte
,char
,short
,int
,long
,float
, anddouble
), and the keywordvoid
are also represented asClass
objects.
The Void
class exists mainly for the sake of the last part of this, so you can write:
Class voidType = void.class; // == Void.TYPE
just like you can write:
Class intType = int.class; // == Integer.TYPE