📄 throwdemo.java
字号:
public class ThrowDemo{
public static void main(String []args){
int i;
try{
for(i=1;i<10;i++){
System.out.println(i);
if(i==1)throw new NumberFormatException("Throw Exception1");
if(i==2)throw new ArithmeticException("Throw Exception2");
if(i==3)break;
}
}catch(NumberFormatException e){
System.out.println("捕捉到 NumberFormatException");
}catch(ArithmeticException e){
System.out.println("捕捉到 NumberFormatException");
}finally{
System.out.println("finally块被执行!");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -