JavaIntermediate#exceptions

What is multi-catch in Java 7+?

A single catch block can handle multiple unrelated exception types using the pipe (|) operator, reducing duplicated catch blocks when the handling logic is identical.

Example
try {
  riskyOperation();
} catch (IOException | SQLException e) {
  System.out.println("Error: " + e.getMessage());
}

Related Questions

1
JavaIntermediate#concurrency

What is a race condition and how do you prevent it?

Open
2
JavaAdvanced#concurrency

What is a deadlock and how can it be avoided?

Open
3
JavaIntermediate#concurrency

What is the difference between synchronized methods and synchronized blocks?

Open