Array is object

Salad Lam - Jan 31 - - Dev Community

Notice

I wrote this article and was originally published on Qiita on 19 September 2019.


Array class is defined in JVM

public class ArrayClassClassloader {

    public static void main(String[] args) {
        System.out.println(boolean[].class.getClassLoader());
    }

}
Enter fullscreen mode Exit fullscreen mode

Output

null
Enter fullscreen mode Exit fullscreen mode

This means that array class is load by bootstrap class loader

Name of array class

public class ArrayClassName {

    public static void main(String[] args) {
        System.out.println(boolean[].class.getName());
        System.out.println(short[].class.getName());
        System.out.println(int[].class.getName());
        System.out.println(long[].class.getName());
        System.out.println(float[].class.getName());
        System.out.println(double[].class.getName());
        System.out.println(char[].class.getName());
        System.out.println(byte[].class.getName());
        System.out.println();
        System.out.println(java.lang.Integer[].class.getName());
        System.out.println();
        System.out.println(int[][].class.getName());
        System.out.println(int[][][].class.getName());
        System.out.println(int[][][][].class.getName());
    }

}
Enter fullscreen mode Exit fullscreen mode

Output

[Z
[S
[I
[J
[F
[D
[C
[B

[Ljava.lang.Integer;

[[I
[[[I
[[[[I
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player