|
Relates :
|
|
|
Relates :
|
A DESCRIPTION OF THE REQUEST :
A natural extension of multicatch added in Java7 is the ability to switch() on Class instances. For example:
try
{
future.get();
}
catch (InterruptedException | ExecutionException e)
{
// Handle exception wrapped by ExecutionException
switch (e.getCause().getClass())
{
case IOException.class:
{
}
case IllegalArgumentException.class:
{
}
// etc
}
}
JUSTIFICATION :
Improved readability. The alternative is a long list of if/else "instanceof" statements.
|