| 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: 14685
|
|
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: 14685
|
|
|
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: 19232
|
|
|
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
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: Void class?
|
|
|