Possible Duplicate:
In a Java 7 multicatch block what is the type of the caught exception?
What Exception type one must assume for the exception variable in Java’s new multi-catch construct:
try{
//-- do error prone stuff
}
catch (ExceptionTypeA | ExceptionTypeB e) {
//-- e.methodA() or e.methodB() ?
}
If ExceptionTypeA and ExceptionTypeB are custom exceptions with custom utility methods, then, what type is e when writing code ?, what methods can one call upon e ?
The type of e will be the closest parent type of both ExceptionA and ExceptionB. if they are just extending Exception, then type will be Exception.
If you are calling different methods for different exception cases like
methodA if ExceptionAandmethodB for ExceptionByou should not be using multi-catch. If both ExceptionA and ExceptionB extends a common supertype and overrides one of it s method, then you could use it.