Java handling multiple exceptions

Last updated on:

Java 7+;

try {
     // stuff
} catch (Exception1 | Exception2 ex) {
     // Handle both exceptions
}

Java 6 and early:

try {

} catch (ExceptionType name) {

} catch (ExceptionType name) {

}
View Comments

Leave a Comment

Use markdown or basic HTML and be nice.