Multi-catch Block
Catching multiple exceptions (Java 7+)
4 min read
Multi-catch
Multi-catch allows handling multiple exceptions in a single catch block.
Code Examples
Multi-catch example
java
1
2try {
3 // code
4} catch (IOException | SQLException e) {
5 e.printStackTrace();
6}
7 Use Cases
- Reducing boilerplate
Common Mistakes to Avoid
- Catching parent and child together