• Post Reply Bookmark Topic Watch Topic
  • New Topic

how can i use Void class?  RSS feed

 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi want to make utilize of Void class an any one please provide me a program for making use of Void Class

thanks in advance
saikrishna
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You did read the bit in the JavaDocs what say's "The Void class is an uninstantiable placeholder class..."?

Void is only really there so you can capture the "return type" of a method called via reflection when there isn't really a return type. Have a look at the class java.lang.reflect.Method and the method getReturnType() to get an indication of where you might use it.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by saikrishna cinux:
hi want to make utilize of Void class an any one please provide me a program for making use of Void Class

thanks in advance
saikrishna


Well I don't know why you want to utlize Void Class.. There are plenty of classes in JAVA which you haven't used so far. Be centric on those classes.

But anyways, I am sure you must be talking about java.lang.Void (wrapper class) ?

public final class Void extends Object. The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void.

static Class<Void> TYPE
The Class object representing the primitive Java type void.

TYPE
public static final Class<Void> TYPEThe Class object representing the primitive Java type void.

Well it can be used it is used in reflection to specify the type of a method, which has no return value.

Well I hope it makes sense for your.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:
You did read the bit in the JavaDocs what say's "The Void class is an uninstantiable placeholder class..."?

Void is only really there so you can capture the "return type" of a method called via reflection when there isn't really a return type. Have a look at the class java.lang.reflect.Method and the method getReturnType() to get an indication of where you might use it.


Oops I didn't seen your reply, that's why I have also replied the same answer almost.....
 
Anand Narayanaswamy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
its really a thought provoking query. But still am not satisfied with it. So can you plese elaborate me with a sample example
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The basic idea could be:


If you are really interested, I suggest you try examining classes with the reflection package and see what you can do. Play around, its the best way to learn.
[ September 26, 2006: Message edited by: Paul Sturrock ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!