?????????????????????????????????????finally

???????3??finally???????


1.try {  
2.   
3.    ......  
4.       
5.} catch (Exception e?? {  
6.    //Todo  
7.} finally {  
8.    ?????????????ò???  
9.    ???????????????????  
10.    ??……  
11.}
 


????????finally???e??????????????

?????????????????е????????????????????????java?У?finally?????????????io??????????????д?????????

??????????????????????java???????????

??????????????????throws??throw??????????????

??????????????????????軺??……

????????throws??java?е???????????????????????

??????????????????????????????????????????????????????

?????????е???????????????????????

?????????????????????????????throws?????????????????

???????4??throws???÷?


1.public void ?????????? throws ??????? {  
2.       
3.    /*??????????????????try...catch??  
4.    ???????У????????????????*/ 
5.       
6.    ......     //??????????????????N?д???  
7.       
8.}
 


???????????????()????????п???try...catch????????????????????????????throws?????????????

???????????????????????????????????????????????????????????????????try?????……

???????????????throw?????????????java?У?throw??????????????????

???????5??throw???÷?


1.public void throwMethod???? throws Exception {  
2.       
3.    throw new ??????????"?????????????"??  
4.       
5.}
 


??????????throwMethod????????????????????????????????????????try

????????catch??????????????????????……?????????19??????а?????

???????????????????API??????????????????????????

??????????????????????????????????????try????????????£?

?????????RuntimeException???????????????????try???try??????????????????????????????????????????????±???????????try...catch???岻???????????????????????????????????????????????????????????????

????????????????????????????????·??????????????????????????????Ч?????????????????????????????????????????????


1.public class CustomException extends Exception {  
2.    public CustomException(String msg) {  
3.        super(msg);  
4.    }  
5.}
 


????????????????????throw????μ?CustomException???????????м?????????????

????????????try...catch?????

???????????????????