I'm using Eclipse and I'm trying to take a string:
1 2 3 4
out of an ArrayList:
ArrayList strings = new ArrayList<>();
And store each number into a two dimensional array:
int size = (int) strings.get(0); // Represents the number of rows
int stringList[][] = new int[size][];
// Store results in a two dimensional array
for(int i = 0; i < size; i++){
int index = i + 1;
String fish = (String) strings.get(index);
Scanner npt = new Scanner(fish);
for(int j = 0; npt.hasNext(); j++) {
size[i][j] = Integer.parseInt(npt.next());
}
}
This is the section that is causing the error:
// ERROR: The type of the expression must be an array type but it resolved to int
size[i][j] = Integer.parseInt(npt.next());