exception api 元件 基礎語法 -...

21
12/11/19 1 Exception API 元件 字串與正規演算式 日期與數字的格式化 printf, Console, Scanner 基礎語法 Checked/UnChecked Exception trycatchfinally 在方法上定義throws XXXException assert來幫助除錯 不應在public方法中用assert來檢查參數 assert的運算式中不應產生副作用

Upload: others

Post on 15-Apr-2020

5 views

Category:

Documents


0 download

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

2

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

4

12/11/19

5

12/11/19

6

12/11/19

7

¡  String + Regular Expression ¡  StringBuffer, StringBuilder ¡  NumberFormat, DateFormat, Locale ¡  Console ¡  Scanner

12/11/19

8

12/11/19

9

12/11/19

10

12/11/19

11

12/11/19

12

¡ 流程控管 §  if...else §  switch…case § 迴圈

¡ 運算子 ¡ 類別、變數、方法

§ 存取範圍 ¡ 陣列

12/11/19

13

12/11/19

14

12/11/19

15

12/11/19

16

12/11/19

17

12/11/19

18

¡ 命令列參數 ¡  -D ¡  -ea ¡  -classpath

12/11/19

19

12/11/19

20

✔ ✔

12/11/19

21