-
catch all
Hi
have been doing a assignment which is running fine apart from one issue on my first menu the user can use 5 options 1,2,3,4,5. but if the user uses a letter by error than oops it all crashes is there a way I can catch everything except 1,2,3,4,5 I thought the default in the switch would of dealt with it but that will only deal with the numbers miss typed.
Thanks
-
Re: catch all
Without code its difficult to pin down the problem, but my guess is you are parsing a string into an integer...with a NumberFormatException being thrown when you attempt to do so on a letter/string. See the following link to figure out how to either catch exceptions or otherwise validate input:
http://www.javaprogrammingforums.com...tring-int.html