So my code should allow you to insert 81 digits in a string "893273872328..." and categorizes them into a matrix in the order typed. My code:
Scanner scan = new Scanner(System.in);
String rawIn = new String(scan.nextLine());
int[][] matIn = new int[8][8];
for(int row = 0; row <=8; row++){
for(int col = 0; col <=8; col++){
matIn[row][col] = Integer.parseInt(rawIn.substring(((row+1)*(col+1)-1),(row+1)*(col+1)));
}
}
But when i run this and enter 81 digits is gives me this:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 8
Any explaination as to why its doing this, is my algorithm flawed?