This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes What is the point of java.lang.Void. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "What is the point of java.lang.Void." Watch "What is the point of java.lang.Void." New topic
Author

What is the point of java.lang.Void.

Mike Forsberg
Greenhorn

Joined: Apr 03, 2002
Posts: 3
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???
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
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.


Rob
SCJP 1.4
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
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 ]

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Mike Forsberg
Greenhorn

Joined: Apr 03, 2002
Posts: 3
Thank's I guess I should search before asking a question.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the point of java.lang.Void.