how to initialize an array in java

Java
int[] arr = new int[10];	//Can hold 10 elementsint[] data = {10,20,30,40,50,60,71,80,90,91};
// or
int[] data;
data = new int[] {10,20,30,40,50,60,71,80,90,91};
// or
int[] data = new int[10];
data = {10,20,30,40,50,60,71,80,90,91};int[] theNumbers = new int[5];

arr[0] = 4;
arr[1] = 8;
arr[2] = 15;
arr[3] = 16;
arr[4] = 23;
arr[5] = 42;type var-name[];
OR
type[] var-name;

Source

Also in Java: