OOB Exception. How to debug?
int sum[]= new int[4], ctr = 0, sums=0;
for(int row=0;row<x.length;row++){
int col = 0;
for(int column=0;column<x[row].length;column++){
sum[row] += x[row][column];
sums += x[row][column];
col += x[column][row];
}
ctr++;
System.out.println("The sum of column " + ctr +": " + col);
System.out.println("The sum of row " + ctr +": " + sum[row]);
}
System.out.println("The sum of all arrays: "+sums);
}
}
This is the code. The problem lies within col += x[column][row];
I'm stuck, Please help. Thanks