Allocate memory
int[] intArray = new int[10];
this will be initialized with zeros
int[] intArray={0,0,0,0};
or
int[] intArray=new int[4]{0,0,0,0};
Filling arrays of the primitive types can also be done with
Arrays.fill(intArray,20);
The above will set all indexes in the intArray to 20
The same can be done with classes e.g:
MyClass[] instances = new MyCLass[10];
or (with parameters)
MyClass[] instances = {new MyClass(10,10),new MyClass(10,10),new MyClass(10,10),new MyClass(10,10)};
I’m not sure if objects are actually created with:
MyClass[] instances = new MyCLass[10];
or if every instance will be null
I also dont know if Arrays.fill() can be used on classes