| Author |
Array class?
|
rakesh sugirtharaj
Ranch Hand
Joined: Dec 16, 2007
Posts: 151
|
|
|
Does array have a corresponding class Class object?
|
Cheers!
RSR
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
private int[] array; . . . array = new int[3]; . . . System.out.println(array.getClass()); Try it.
|
 |
rakesh sugirtharaj
Ranch Hand
Joined: Dec 16, 2007
Posts: 151
|
|
I did this
package mypack; public class Test { public static void main( String[] args) { int[] array; array = new int[3]; System.out.println(new Test().getClass()); System.out.println(array.getClass()); System.out.println("After array class"); } }
and i got the output as
class mypack.Test class [I After array class
I dont understand the meaning of that class [I.... Can anyone explain whats going on?
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24061
|
|
|
The "name" of an array class is an open-bracket for each dimension of the array, followed by a descriptor that stands for the type of the array elements. So [I is an array of int, [[D is a double[][], and [java/lang/String; is a String[] .
|
[Jess in Action][AskingGoodQuestions]
|
 |
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
|
|
Try this also.
|
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
|
 |
 |
|
|
subject: Array class?
|
|
|