Glad you got it work.
Just for the record, you can take the input evaluation (if...else block) outside the try...catch block since in the latter you are just checking for the exception.
Type: Posts; User: andreas90
Glad you got it work.
Just for the record, you can take the input evaluation (if...else block) outside the try...catch block since in the latter you are just checking for the exception.
It "complains" becaused you took away the else block and therefore there is case that the method will not return anything. For example if the selection is out of the entered bounds.
"exceptionthatmaybethrown" was just fordemonstration. You should catch the exception that actually may be thrown which in your case is the NumberFormatException.
The try block should contain the...
try {
//code that may throw the exception, the parsing method
} catch (ExceptionThatMayBeThrown e) {
e.getStackTrace();
return INVALID;...
Hello Max!
If I'm getting it right you want the method to return INVALID when it throws an exception. I think you can do that by surrounding the part of code that may through the exception (in your...