要捕获与继承无关的多个不同异常,请对单个尝试使用多个catch块
/*nowjava.com - 时代Java 提 供*/ try { // code that might generate exceptions } catch (IOException ioe) { System .out.println ("Input/output error"); System .out.println (ioe.getMessage ()); } catch (ClassNotFoundException cnfe) { System .out.println ("Class not found"); System .out.println (cnfe.getMessage ()); } catch (InterruptedException ie) { System .out.println ("Program interrupted"); System .out.println (ie.getMessage ()); }