I dont understand what is wrong with this code. I want to read txt file
11,10
2,20
into array[][] in java.
My code is
import java.util.Arrays;
class ArrayMatrix{
public static void main (String[] args) {
int rows = 2;
int cols = 2;
FileInput in = new FileInput("test.txt");
int[][] circle = new int[rows][cols];
int i = 0;
int j = 0;
String [] line;
for(i = 0; i<rows; i++) {
line = in.readString().split(",");
for(j = 0; j<cols; j++) {
circle[i][j] = Integer.parseInt(line[j]);
System.out.println(circle[i][j]);
}
}
}
}
The output is
11
10
2
20
Could you please help me understand why please?
I want the output
11 10
2 20