产品库存管理系统面向对象设计培训(课件.ppt

产品库存管理系统面向对象设计培训(课件.ppt

多重 catch 块2-2 try{ …... } catch(Exception e) { …… } catch(ArrayIndexOutOfBoundsException e) { …… } × 使用多重 catch 语句时,异常子类一定要位于异常父类之前。 多重 catch 块示例 class ExceptionCode { public void calculate() { try { int num = 0; int num1 = 42 / num; int c[] = { 1,2,3,4 }; c[4] = 99; }catch (Exception e) { System.out.println(父类异常 catch 子句); }catch (ArithmeticException ae) { // 错误 – 不能到达的代码 System.out.println(这个子类的父类是exception 类,且不能到达); } } } class UnreachableCode { public static void main(String[] args) {

文档评论(0)

1亿VIP精品文档

相关文档