Possible duplicate:
Why is there no java.lang.Array class? If the java array is an object, should it not extend Object?
I created an array:
int a[] = new int[50];
Here intis a primitive data type, but in java , arrays are created at runtime, which means there will be an object of some class.
So, I would like to know what class the object they are and what happens in the background process when creating an array object ?
And one more thing I would like to know if I wanted to print the reference identifier of this array:
System.out.println(a);
then the output will be a specific view. [I@17182c1
Here I know that the line before @ is the name of the class and after @ is the hash code. But what class [I?
How is the class created [Iand where did I get the variable lengththat returns the length of the array? I did not find the class [Iin the whole Java API, then why the compiler does not show an error if I write:
System.out.println(a.length);
since the class [Iwill be created at runtime?
source
share