• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Array class?

 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does array have a corresponding class Class object?
 
Marshal
Posts: 82459
594
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
private int[] array;
. . .
array = new int[3];
. . .
System.out.println(array.getClass());

Try it.
 
rakesh sugirtharaj
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author and iconoclast
Posts: 24208
47
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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[] .
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this also.
reply
    Bookmark Topic Watch Topic
  • New Topic