Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Void Class

 
anil kumar bolisetti
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the Usage of Void Class
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Javadoc explains that "The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void.". The reflection API is a set of classes and methods that let you find out things about Java classes at runtime -- i.e., you can ask what methods a class has, what its superclass is, etc. You can also ask what a method's return type is, what its argument types are, etc.

If you ask what a method's return type is, and that method returns void, you get the static final member Void.TYPE . That is the only purpose of the Void class.
 
anil kumar bolisetti
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Ernest for the information given.
If possible can you give an example how can we use it.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a simple example. You can learn more about reflection in the Reflection Tutorial.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic