Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Reflection: Get a Class-Iinstance of a Wrapper Class - why .TYPE?

Reply
Thread Tools

Reflection: Get a Class-Iinstance of a Wrapper Class - why .TYPE?

 
 
Julian
Guest
Posts: n/a
 
      05-24-2005
Good morning,

can anyone explaine me the reason why every Wrapper-Class (like
Integer) has this special constant .TYPE? These Wrapper-Classes provide
the normal getClass()-Method as well and I therefore don't understand
the sense of the .TYPE constant.
Thank you very much in advance!

Greetings from sunny Kiel

Julian Wissel

 
Reply With Quote
 
 
 
 
Roland
Guest
Posts: n/a
 
      05-24-2005
On 24-5-2005 10:50, Julian wrote:
> Good morning,
>
> can anyone explaine me the reason why every Wrapper-Class (like
> Integer) has this special constant .TYPE? These Wrapper-Classes provide
> the normal getClass()-Method as well and I therefore don't understand
> the sense of the .TYPE constant.
> Thank you very much in advance!
>
> Greetings from sunny Kiel
>
> Julian Wissel
>

It represents the class of the *primitive*, i.e. not the class of the
wrapper class.

Wrapper Primitive
Integer.class int.class (== Integer.TYPE)
Character.class char.class (== Character.TYPE)
Float.class float.class (== Float.TYPE)
etc.

Used when obtaining a Method that has a primitive parameter. E.g. to get
the static method toString(int) of class Integer:

Integer.class.getDeclaredMethod("toString", new Object[]{Integer.TYPE});

or

Integer.class.getDeclaredMethod("toString", new Object[]{int.class});
--
Regards,

Roland de Ruiter
___ ___
/__/ w_/ /__/
/ \ /_/ / \
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why no maintained wrapper to Win32? Gilles Ganault Python 12 07-31-2007 07:53 PM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Re: Coding a c# wrapper class to unmanaged C++ program, need some guidance Brendan Duffy ASP .Net 0 07-25-2003 12:49 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57