When new keyword is encountered in java an object is created and a constructor is called.
So which constructor is called when an array object is created.
Eg int[] a = new int[];
We know that array are Objects.
Arrays don't use contructors to initialize. If you try to compile int[] array = new int[10];
you would get something like the below bytecode:
bipush 10
newarray int
astore_1
On the other hand, the bytecode instructions for Person p = new Person();
would look like the below (notice the call to new
and init
denoting the call to the constructor):
new test/Person
dup
invokespecial test/Person/<init>()V
astore_2
Hence arrays have their own way of creation in the JVM that is different than creating class objects.