/** * 捕捉多个异常方法 */ class MultiCatch { public static void main(String args[]) { try { int a = args.length; System.out.println("a = " + a); int b = 42 / a; int c[] = { 1 }; c[42] = 99; } catch (ArithmeticException e) { System.out.println("div by 0: " + e); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("array index oob: " + e); } catch (Throwable t) { System.out.println("got t: " + t); } } }