Originally Posted by
andbin
No, both are wrong (for syntax and meaning).
This reads 1 integer token (where
inData is the reference to your Scanner instance):
int value = inData.nextInt();
While the following fills an int[] (monodimensional):
int[] arr = new int[10];
for (int i = 0; i < arr.length; i++) {
arr[i] = inData.nextInt();
}
Your case is slightly different: you have a
bidimensional array. Thus, do a double-for loop and into this loop read the integer token and assign the value to the array element at row/column i,j.
Sorry I didn't say anything. I was able to get the numbers from the .txt into my array. Thank you very much for the help. Here is the code I got:
for(i = 0; i < array07.length; i++) {
for(j = 0; j < array07[i].length; j++) {
array07[i][j] = inData.nextInt();
It worked like this. Again, thank you.