DEV Community

Salad Lam
Salad Lam

Posted on

Array is object

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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay