Reputation: 47
hey guys the compiler keeps giving me a cannot find symbol for the try-catch here.. i'm trying to scan for a int but i have to user input error check for other stuff and yet i cant seem to be able to catch the exception..
try
{
starid = sc.nextInt();
}catch(InputMismatchException e)
{
System.out.println("Error in input!!");
}
Thanks in advance guys...
Upvotes: 2
Views: 13091
Reputation: 5075
Really hard to tell, from seven lines of code.
Other than what Jon said, you might not have initialized starid
(e.g. int starid = null ;
). Please post the exception stack or full error description.
Upvotes: 0
Reputation: 1503090
Do you have the right import for InputMismatchException
, e.g.
import java.util.InputMismatchException;
or
import java.util.*;
If you could post the exact error message, that would be helpful.
Upvotes: 6