Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wrapper classes

 
Ramakrishnan Ponmudi
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?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrapper class? What is that?
 
Gianfranco Alongi
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
Eclipse IDE Hibernate 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
 
Dirk Schreckmann
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic