int[] scores; //①
scores = new int[5]; //②
[5] = 0,1,2,3,4 Counting from zero contents [5]
int[] scores = new int[5]; //①②
int[] scores1 = new int[] {10, 20, 30, 40, 50};
int[] scores2 = {10, 20, 30, 40, 50};
Same meaning up and down
int[] scores = {10, 20, 30, 40, 50};
for (int i = 0; i < scores.length; i++) {
System.out.println(scores[i]);
Loop variable name can be specified arbitrarily
int[] scores = {10, 20, 30, 40, 50};
for (int value : scores) {
System.out.println(value);
There is no need to write loop variables and array subscripts in the above for statement`
** Array length ** ** String length () **
Recommended Posts