This wasn't possible before Java 7, Use this syntax for Java 7+:
try {
//.....
} catch ( IllegalArgumentException | SecurityException |
IllegalAccessException |NoSuchFieldException exc) {
someCode();
}
It's worth mentioning, that if all the exceptions apply to the same class hierarchy, we can easily catch that base exception type.
And we cannot catch both ExceptionA and ExceptionB in the same block if ExceptionB is inherited, both directly or indirectly, from ExceptionA. The compiler will complain:
Alternatives in a multi-catch statement cannot be related by subclassing
Alternative ExceptionB is a subclass of alternative ExceptionA
So you need to take care of it.