I'm getting the following error output when trying to run my code.
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:907)
at java.util.Scanner.next(Scanner.java:1416)
at Olympics.main(Olympics.java:61)
Java Result: 1
The project includes a text file called olympics.txt and is a file of statistics of Olympic athletes with their countries etc. I have the number of lines in the file, lineNum, and am using this for loop to add each piece of information into corresponding arrays.
for(int j = 0; j <= lineNum-1; j++)
{
String line = fileScan.nextLine();
Scanner lineScan = new Scanner(line);
lineScan.useDelimiter("\t");
name[j] = lineScan.next();
age[j] = lineScan.nextInt();
country[j] = lineScan.next();
year[j] = lineScan.next();
String ceremony = lineScan.next();
sport[j] = lineScan.next();
int gold = lineScan.nextInt();
int silver = lineScan.nextInt();
int bronze = lineScan.nextInt();
total[j] = lineScan.nextInt();
}
Line 61 is the age[j] = lineScan.nextInt();
I commented the age line out to see if it worked then, but it still didn't work. Any help is appreciated, and if you need more code, then let me know.