List<Void>
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<Void>
. From the docs for Class
:
The primitive Java types (boolean
, byte
, char
, short
, int
, long
, float
, and double
), and the keyword void
are also represented as Class
objects.
The Void
class exists mainly for the sake of the last part of this, so you can write:
Class<Void> voidType = void.class; // == Void.TYPE
just like you can write:
Class<Integer> intType = int.class; // == Integer.TYPE