• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

void

 
lusha tak
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldn't undersatnd why do we consider void as a primitive type and what we go to do with the Wrapper class Void ???
please explain
Regards
Lusha
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lusha,
According to the API documentation:

The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void.

What that means is that you don't do anything with it! Since it can't be instantiated (private constructor) you can't use it. Since it is final you can't override it. Therefore, it only exists to provide a placeholder for the class type holding the void variable.
Regards,
Manfred.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The keyword "void" is NOT a primitive type. In the Java language, there are only 8 primitive types: boolean, byte, char, short, int, long, double, and float. Only these primitive types have a corresponding wrapper class; these are Boolean, Byte, Character, Short, Integer, Long, Double, and Float, respectively.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the Void class is used for reflection.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic