This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Void class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Void class? " Watch "Void class? " New topic
Author

Void class?

santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
hi friends

Please giude me the concept of void class in java.lang package..... with example


Creativity is nothing but Breaking Rules
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

It's used to express the "void" keyword. I use it with the java.util.concurrent.Callable interface, to say that I'm not expecting any returned value from the executed thread.


[My Blog]
All roads lead to JavaRanch
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
Christophe Verré wrote:It's used to express the "void" keyword. I use it with the java.util.concurrent.Callable interface, to say that I'm not expecting any returned value from the executed thread.


hi friend ...... as you told it is used to express the void keyword... then what is the difference between keyword void and class void...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

In my example, you need a Class to be used as a generic type. "void" is just a keyword, it cannot be used for generic types. You cannot use "new Callable<void>". To correct this, you must use the Void class instead.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Also, Void.TYPE is what will be returned from Method.getReturnType() for methods that return nothing (void). That's probably where the entire class was originally created for, since generics didn't exist until Java 5.0, but Void exists since Java 1.1.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Void class?
 
Similar Threads
Void class
can't run
Difference between
void
Void Class