Multi catch exceptions


Source code

1import java.net.MalformedURLException;
2import java.text.ParseException;
3
4class MultiCatchExceptions {
5
6 void catchMalformedURLExceptionAndParseException() throws MalformedURLException, ParseException {
7 try {
8 malformedURLException();
9 parseException();
10 } catch (MalformedURLException | ParseException exception) {
11 exception.hashCode();
12 throw exception;
13 }
14 }
15
16 void catchMalformedURLExceptionAndParseException2() throws MalformedURLException, ParseException {
17 try {
18 malformedURLException();
19 parseException();
20 } catch (Exception exception) {
21 throw exception;
22 }
23 }
24
25 void catchMalformedURLException() {
26 try {
27 malformedURLException();
28 } catch (MalformedURLException exception) {
29 exception.hashCode();
30 }
31 }
32
33 void catchParseException() {
34 try {
35 parseException();
36 } catch (ParseException exception) {
37 exception.hashCode();
38 }
39 }
40
41 void malformedURLException() throws MalformedURLException {
42 }
43
44 void parseException() throws ParseException {
45 }
46
47}

Bytecode



Java compiler version: 21
Other examples
Main page