hi im trying to do a bit of small validation in my code but, when i try to try catch a large area of text (like the one below) i get the error message above the catch which says “Cannot Find Symbol” can someone point me in the right direction in what im doing wrong?
Any help is appreciated
try{
while (option != 0) {
}//End Loop
} catch(InputMismatchException e) {
System.out.println("\nNot a number or an integer!\n");
option = menuSystem();
}
}
}//End OF Class
I guess your
try/catchis not included inside any method implementation.The telltale is that you close curly brace of class just after
catch‘s curly brace! Where is the curly brace for method?Do you have at least a
mainmethod (or other) containing your code?For sure, if you start coding just after the class declaration, this will lead to some alerts/errors. Example:
Your issue is not caused by the missing identifier for exception.
In that case, you would end up with a “identifer expected” alert.
Besides, remove the last curly brace after the end of class.