File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Array class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Array class?" Watch "Array class?" New topic

Array class?

rakesh sugirtharaj
Ranch Hand

Joined: Dec 16, 2007
Posts: 151
Does array have a corresponding class Class object?

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46362
private int[] array;
. . .
array = new int[3];
. . .

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("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

Joined: Jul 08, 2003
Posts: 24199

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
I agree. Here's the link:
subject: Array class?
It's not a secret anymore!