异常的分类(cont.) “如果出现RuntimeException,则一定是你的 错误” Error的子类以及RuntimeException[的子类称 为末检查(unchecked)异常 其他的异常都被称为已检查(checked)异常 ©2006计算机系杨厚群 All rights lefts reserved
©2006 计算机系 杨厚群 All rights & lefts reserved. 异常的分类(cont.) “如果出现RuntimeException,则一定是你的 错误” Error的子类以及RuntimeException的子类称 为未检查 (unchecked)异常 其他的异常都被称为已检查(checked)异常
声明、抛出和捕获异常 methodl() 4444444444444444 method2 ( throws Exception claim exception if (an error occurs) try catch exception throw new Exception(); throw exception invoke method2; } catch (Exception ex) Process exceptio; ©2006计算机系杨厚群 All rights lefts reserved
©2006 计算机系 杨厚群 All rights & lefts reserved. 声明、抛出和捕获异常 method1() { try { invoke method2; } catch (Exception ex) { Process exception; } } method2() throws Exception { if (an error occurs) { throw new Exception(); } } catch exception throw exception claim exception