五個常見異常的案例

2021-09-25 23:17:27 字數 1139 閱讀 5894

1.算術異常:arithmeticexception

2.字元索引越界異常:arrayindexoutofbound***ception

3.空指標異常:nullpointerexception

4.正規表示式語法異常:patternsyntaxexception

5.陣列為負異常:negativearraysizeexception

public

class

work03

catch

(arithmeticexception e)

catch

(exception e)

system.out.

println

("執行1");

int[

] arrint=

;try

catch

(arrayindexoutofbound***ception e)

system.out.

println

("執行2");

string str=

null

;try

}catch

(nullpointerexception e)

system.out.

println

("執行3");

string str01=

"賬號:asd1234 密碼:asazddefe"

+"賬號:safg134534 密碼:asazddefe"

+"賬號:1646465df 密碼:asazddefe"

;try

密碼:[0-9a-za-z]");

matcher m=p.

matcher

(str01)

;while

(m.find()

)}catch

(patternsyntaxexception e)

system.out.

println

("執行4");

trycatch

(negativearraysizeexception e)

system.out.

println

("執行5");

}}

異常 常見的異常

在程式設計中異常處理會被頻繁的使用,所以有必要知道一些常見的異常。nullpointexception 空指標異常,屬於執行時異常。簡單來說就是呼叫了未經初始化的物件或者不存在的物件,或者是訪問或修改null物件的屬性或方法。classnotfoundexception 找不到類異常。出現這種情況一...

常見的異常

arithmeticexception 由於除數為0引起的異常 arraystoreexception 由於陣列儲存空間不夠引起的異常 classcastexception 一當把乙個物件歸為某個類,但實際上此物件並不是由這個類 建立的,也不是其子類建立的,則會引起異常 illegalmonitor...

五個部署Hyper v的常見錯誤

微軟的hyper v使用已經非常容易了,它不需要有專門的技能,就可以設定乙個虛擬機器的啟動和執行,即便有安裝嚮導和最佳實踐,但是還是有人會犯一些常識性的錯誤.以下五個常見的錯誤是我看見很多人在部署hyper v時常犯的,我們如何去避免它們呢?1忽視網路管理 當你新增你的第乙個hyper v角色的時候...