Can I catch multiple Java exceptions in the same catch clause?

This has been possible since Java 7. The syntax for a multi-catch block is: try { … } catch (IllegalArgumentException | SecurityException | IllegalAccessException | NoSuchFieldException e) { someCode(); } Remember, though, that if all the exceptions belong to the same class hierarchy, you can simply catch that base exception type. Also note that you … Read more