Java 7 has a new way to catch multiple exceptions in a single catch , as shown below.
try { //stuff that causes one or more of the exceptions below. } catch (IOException | IllegalArgumentException | IndexOutOfRangeException ex) { //one of the above exceptions was thrown and caught //this code block will run if any of the above exceptions was caught }
What other programming languages, if any, have a similar way of catching multiple exceptions in one block or removing the need to use a catch for each exception? How do these languages โโimplement this catch of several exceptions?
source share