Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Void is Wrapper Class

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
can anybody tell me
Void is wrapper class ???
Thanx
Aftab
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
void is a keyword and Void is a wrapper class. Im not sure what its use is, it doesnt seem to do much.
public final class Void
extends Object
The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.
does anyone know a use for this class?
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One reason why wrapper classes exist in java is that they can be substituted where an Object is required as the wrapper classes too subclass Object. Any method which takes an Object as a parameter, can take Integer or Float or other wrapper classes also.
Since Java does not require void to be specified in a method with no paramters, I dont think Void wrapper class will be of any use here.
However, in cases where an Object is required as a return type of a method, Void wrapper class can be used to return nothing.
 
Randall Twede
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
another main use of wrappers is so you can put primatives in containers but I cant think of why you might need to do that with Void . that is why I was wonderng what it is for. I can see how you might have a method as you describe though.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
'rajni_singh'
Your name does not comply with the JavaRanch naming policy. Please choose one that meets the requirements.
Javaranch appreciates your cooperation to comply with the official naming policy.
Ajith
 
pie. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic