Garee
Garee
I am working on one of my university Java course assessments and I keep experiencing this error.
This occurs in my Person class constructor.
The Scanner in this case is reading from a text file containing details of some people in the format:
The problem seems to be the delimiter "," as the code compiles correctly when I only use .next()
Any help is much appreciated, thanks.
Code:
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at Person.<init>(Person.java:49)
at ProcessMembers.main(ProcessMembers.java:22)
This occurs in my Person class constructor.
Code:
public Person( Scanner inputScanner )
{
this.lastName = inputScanner.next();
this.firstName = inputScanner.next(",");
this.male = Gender( inputScanner.next(",") );
this.dateOfBirth = new Date( inputScanner.nextInt(), inputScanner.nextInt(), inputScanner.nextInt() );
}
The Scanner in this case is reading from a text file containing details of some people in the format:
Code:
Adams Bill, M, 16 03 63
The problem seems to be the delimiter "," as the code compiles correctly when I only use .next()
Any help is much appreciated, thanks.