try-catch语句范例

package Exception;

/**
* @author solang
* @date 2021-08-31 16:09
*/
public class Example20 {
public static void main(String[] args) {
try {
int result=divide(4,0);
System.out.println(result);
}catch (Exception e){
System.out.println("捕获的异常信息为:"+e.getMessage());
return;
}finally {
System.out.println("进入finally语句块");
}
System.out.println("程序继续执行");
System.out.println("刘品水nb");

}
public static int divide(int x,int y){
int resulut=x/y;
return resulut;
}
}

 

posted @ 2022-03-19 00:04  刘品水  阅读(114)  评论(0编辑  收藏  举报