File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes void Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "void" Watch "void" New topic


lusha tak
Ranch Hand

Joined: Dec 30, 2000
Posts: 185
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
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
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.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: May 05, 2000
Posts: 13974
I think the Void class is used for reflection.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
I agree. Here's the link:
subject: void
It's not a secret anymore!