// Java: How to represent 1d string/int array into 2d int array? I would really appreciate your help.
package intro;
public class ArrayTest{
public static void main(String[] args) {
int arr[][]= new int[4][4];
int month_days [] = {31,28,31,30,31,30,31,31,30,31,30,31,13,14,15,16};
int size =4;
//System.out.println(size);
for (int i = 0, k = 0; i < size; i++, k++) {
for(int j=0; j <size; j++){
arr[i][j]= month_days[k++];
//System.out.println(month_days[k++] + " ");
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}
ArrayTest.java:13
refers to the class (ArrayTest.java
) and line number (13
) in which the error occurs.