im trying to convert this 1D array to a 2D array but I cant get it to work.
public static void main ( String args [] ){
int [] scanned={1,2,3,4,5,6,7,8,9,10,11,12};
int row=4;
int col=3;
int[][] skydata=new int[row][col];
for(int r=0; r<row; r++){
for( int c=0; c<col; c++){
for(int i=0; i<row*col; i++){
skydata[r][c]=scanned[i];
}
}
}
System.out.print(Arrays.deepToString(skydata));
this gives an output of the last element [[12,12,12] [12,12,12] etc.
my goal is to copy it so that the 2d array outputs as follows [[1,2,3],[6,5,4][7,8,9],[12,11,10]
so what Am i doing wrong?