• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

wrapper classes

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i can't understand Wrapper class field TYPE,
what is the purpose of TYPE field and
why it is of type Class?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrapper class? What is that?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Class used to "wrap" (like the name implies) an object..
For example,, the Wrapper class Integer can be used to parse values..
String t = "10";
int t_val= Integer.parseInt(t);
Which gets the numerical value from the String and passes it to the t_val;
Now, there are quite a few usefull wrapper-classes..
like:
Integer
Float
Double
....
Most of them have a capital letter to distinguise them from their
native type...
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes thank you Gianfranco Alongi, I am well aware of the concept of a wrapper class. What I am not familiar with is a class called "Wrapper" in any version of the JDK. So what I'd like from Thanjai ramakrishnan is some hint of which class he's talking about. Otherwise, his question is hard to answer.
 
Ramakrishnan Ponmudi
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Paul Sturrock:
Yes thank you Gianfranco Alongi, I am well aware of the concept of a wrapper class. What I am not familiar with is a class called "Wrapper" in any version of the JDK. So what I'd like from Thanjai ramakrishnan is some hint of which class he's talking about. Otherwise, his question is hard to answer.


it's not Wrapper ,its wrapper class
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick look at the API documentation for the Integer class (or for any of the wrapper type classes) reveals just what Thanjai is asking about.
what is the purpose of TYPE field and why it is of type Class?
The purpose of the TYPE field is, as the documentation says, to be able to acquire a Class instance representing the primitive type of the wrapper class.
So, then a good question might be, "Why would someone want a Class instance representing some primitive some?"
To a large extent, the answer to that question ventures in to the realm of reflection. For an introduction to that subject, I'd suggest taking a look at The Reflection API Trail of Sun's Java Tutorial.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!