Java常見異常

2021-08-27 09:24:10 字數 285 閱讀 7081

1.nullpointerexception——空指標異常,為執行時異常,當物件為null時呼叫物件方法產生。

2.classnotfoundexception——找不到類檔案異常,為檢測性異常,當指定的類檔案不存在時產生。

3.arrayindexoutofbound***ception——陣列索引越界異常,為執行時異常,在運算元組時使用的陣列索引不在陣列的索引範圍內。

4.classcastexception——型別轉換異常,為執行時異常,在進行型別轉換時,由於被轉換的物件的型別不能轉換為目標型別時產生。

Java常見異常

手打一遍加深印象 異常類說明 classcastexception 型別轉換異常 classnotfoundexception 未找到相應類異常 arithmeticexception 算術異常 arrayindexoutofbound ception 陣列下標越界異常 arraystoreexce...

java常見異常

算術異常類 arithmeticexecption 空指標異常類 nullpointerexception 型別強制轉換異常 classcastexception 陣列負下標異常 negativearrayexception 陣列下標越界異常 arrayindexoutofbound ception...

Java 常見異常

try 嘗試 catch 捕捉 finally 最後 throw 丟擲 throws 投擲 表示強制異常處理 throwable 可丟擲的 表示所有異常類的祖先類 在這裡插入 片arrayindexoutofbound ception 陣列下標越界異常 arithmeticexception 算術異...