aspose file tools*
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 Spring in Action this week in the Spring 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: 14688
    
  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: 14688
    
  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: 19722
    
  20

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?