This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Array class?  RSS feed

 
rakesh sugirtharaj
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does array have a corresponding class Class object?
 
Campbell Ritchie
Sheriff
Posts: 55292
156
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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[] .
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this also.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!