wood burning stoves 2.0*
The moose likes Java in General and the fly likes Class of array? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Class of array?" Watch "Class of array?" New topic
Author

Class of array?

Kousik Majumder
Ranch Hand

Joined: Sep 30, 2007
Posts: 229
Hi all,

Can somebody tell me what are the class of all primitive types?
Except String.....
e.g-> int obj[] = new int[2];

which class's object is obj?

Thanks,
Kousik


Thanks in Advance,
Kousik
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Java Language Specification �10.8. There is a list of what the 8 letters are, but I can't seem to find it. I think they are B (byte) C D F I L S and Z (boolean). They are mostly the initials of the primitive types, but in upper case.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
I have found a list of the letters in a book (Lemay and Cadenhead, teach yourself Java2 in 21 days, SAMS, 2/e, page 479).
B byte
C char
D double
F float
I int
J long
L object
S short
Z boolean
As you have seen from the link I gave earlier, there is an associated [ and [L is followed by the name of the class
[ September 09, 2008: Message edited by: Campbell Ritchie ]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Originally posted by Kousik Majumder:
e.g-> int obj[] = new int[2];

which class's object is obj?

The simple answer: int[].class

You see it right: you can use .class with arrays as well. You can even use it with the primitive types: int.class will return the class that represents int in reflection. You can also find that one through Integer.TYPE.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
wood burning stoves
 
subject: Class of array?
 
Similar Threads
SCJP: Threads Qs
confusion in if condition
Please help explain the deadlock.
TypeFactory can it be done in java?
Operators