Since it is a memorandum memo, details are not described.
Creating an array
・ How to declare an array
It is flexible and can be declared as follows. The number of [] can be used to determine the number of dimensional arrays.
① int[] a; ② int a[]; ③ int [] [] a; Two-dimensional array ④ int [] a []; Two-dimensional array ⑤ int [] [] a []; 3D array
-Generation of array instance
int[] num = new int[3]; int [] num = new int [2 * 3]; * Calculation formula to return an int type value
String[] str = {“A”,”B”,”C”};
int [][] num = new int[2][]; num[0] = new int[3]; num[1] = new int[2];
It is also possible to specify different numbers of elements as described above.
Recommended Posts