This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 227
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: 36478
    
  16
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: 36478
    
  16
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: 19541
    
  16

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
 
 
subject: Class of array?
 
Similar Threads
confusion in if condition
TypeFactory can it be done in java?
SCJP: Threads Qs
Please help explain the deadlock.
Operators