exception api 元件 基礎語法 -...
TRANSCRIPT
12/11/19
1
¡ Exception ¡ API 元件
§ 字串與正規演算式 § 日期與數字的格式化 § printf, Console, Scanner
¡ 基礎語法
¡ Checked/UnChecked Exception ¡ try…catch…finally ¡ 在方法上定義throws XXXException ¡ 用assert來幫助除錯
§ 不應在public方法中用assert來檢查參數 § assert的運算式中不應產生副作用
12/11/19
3
✔
class A { public void method1() { try { B b = new B(); b.method2(); } catch (TestException ex) { throw new RuntimeException(); } } } class B { public void method2() throws TestException { throw new TestException(); } } class TestException extends Exception {}
✔
12/11/19
7
✔
✔
✔
¡ String + Regular Expression ¡ StringBuffer, StringBuilder ¡ NumberFormat, DateFormat, Locale ¡ Console ¡ Scanner