aspose file tools*
The moose likes Beginning Java and the fly likes wrapper classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "wrapper classes " Watch "wrapper classes " New topic
Author

wrapper classes

Ramakrishnan Ponmudi
Ranch Hand

Joined: Apr 20, 2004
Posts: 72
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

Joined: Apr 14, 2004
Posts: 10336

Wrapper class? What is that?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Gianfranco Alongi
Greenhorn

Joined: Apr 20, 2004
Posts: 5
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...


Faster machines are a bad excuse<br />for writing unoptimized code<br />Like java...
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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

Joined: Apr 20, 2004
Posts: 72
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

Joined: Dec 10, 2001
Posts: 7023
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.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: wrapper classes