1 package test4; 2 3 public class MultiCatch { print()4 public void print() { System.out.println("MultiCatch"); } test1()5 public int test1() { return m1(1); } m1(int i)6 public int m1(int i) { 7 // Java 7 syntax 8 try { 9 return foo(i); 10 } 11 catch (java.io.IOException | NullPointerException e) { 12 return e.getMessage().length(); 13 } 14 } foo(int i)15 public int foo(int i) throws java.io.IOException { 16 if (i < 0) 17 throw new java.io.IOException("negative"); 18 else if (i < 10) 19 throw new NullPointerException("less than 10"); 20 else 21 return i; 22 } 23 } 24