(For int)
int[] arr = new int[5];
arr[0] = 3; //Substitute 3 for the first (first) element
arr[1] = 1; //Substitute 1 for the second element
arr[2] = 6; //Substitute 6 for the third element
arr[3] = 0; //Substitute 0 for the 4th element
arr[4] = 4; //Substitute 4 for the 5th element
int[] arr = {3, 1, 6, 0, 4};
(When the number of elements is 3)
System.out.println("Number of elements in array arr ..." + arr.length);
result:Number of elements in array arr ... 3
Recommended Posts