Catching More Than One Exception in One Catch Block
Posted: Tue Feb 26, 2013 4:52 pm
Hi,
Why below code is giving compilation error at catch statement
try{
// some of my codes
}catch(IOException|SQLException ex){
ex.printStackTrace();
}
I am getting below compilation error
IOException.SQLException cannot be resolved to a type
- Syntax error on token "|", . expected
As per the API we can have multiple exception handling in one catch.
Why below code is giving compilation error at catch statement
try{
// some of my codes
}catch(IOException|SQLException ex){
ex.printStackTrace();
}
I am getting below compilation error
IOException.SQLException cannot be resolved to a type
- Syntax error on token "|", . expected
As per the API we can have multiple exception handling in one catch.