blob: 4aa8b59877d62d553c207fe648ed89b199df5a3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
public class MathsTest2 {
/**
* @param args
*/
public static void main(String[] args) {
Maths m = new Maths();
int result = 0;
try {
result = m.factorial(-5);
} catch(MathsException me) { // Catching a specific exception
System.err.println("Caught a MathsException");
} catch(Exception e) { // Catching the super type
System.err.println("Caught an Exception");
}
try {
result = m.factorial(-5);
} catch (MathsException | ArrayIndexOutOfBoundsException e) { // Java SE 7
}
System.out.println(result);
}
}
|