File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 234
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: 40061
    
  28
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: 40061
    
  28
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: 19794
    
  20

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class of array?