How to resolve exception error

Asked By 20 points N/A Posted on -
qa-featured

 After attempting to run a program that I have remotely used, an error occurred "Exception in thread "main" java.util.InputMismatchException" during commanding the date as 11/11/2010. Why this problem occurred and which way I can solve it?

Moreover I have to do some fact which is displayed in the program as comments, but I am not capable of solving it with my own merit. Please help about this topic always accepted cordially.

SHARE
Answered By 0 points N/A #94333

How to resolve exception error

qa-featured

 

It is thrown in by a Scanner to point out that the token retrieved does not match the pattern for the expected type, or that the token is out of range for the expected type. 

It means that your program has tried to read a value that is an integer that is not an integer that is you have a integer like a comma at the end of the line. That means Scanner will assume there is something after the integer, in this case an empty String. It is impossible to get an int out of an empty String, so you get the exception.

Try looking at API and see if it’s reading a empty string off the end of the first line and cannot form it into a number.

You may consider calling the nextLine() or nextLine() , or next() call, butnextLine() on your scanner after the end of each line.

Related Questions