• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is the point of java.lang.Void.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if this is the correct place for this question, but here it is.
While studying for the SCJP, my group came across the java.lang.Void class. We understood that it represents the primative return type Void. What is its purpose? Is it only used as a place holder for reflection calls???
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the JavaDoc:
The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.
It's there so you can do
Class voidClass = void.class;
for completeness with the other Class literals.
Now, *why* you would need to do this, I don't know. But someone in java-land thought it was important, so there ya go.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's part of reflection. The method Method.getReturnType() returns a Class type. The Void class holds a Class object representing the void type.
[ April 03, 2002: Message edited by: Thomas Paul ]
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
void is not a primitive type. Please refer to the following discussion:
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=013732
 
Mike Forsberg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank's I guess I should search before asking a question.
 
reply
    Bookmark Topic Watch Topic
  • New Topic