📄 throwsexception.java
字号:
public class throwsException
{ public static void main(String args[ ])
{ try
{ Method(0);
Method(1);
}
catch(NumberFormatException e)
{ System.out.println("\t 捕获异常:"+e);}
catch(ArrayIndexOutOfBoundsException e)
{ System.out.println("\t 捕获异常:"+e);}
finally
{ System.out.println("\t finally 块总是被执行。");}
}
static void Method(int i) throws ArithmeticException,NumberFormatException
{ System.out.println("\t 调用方法 Method("+i+")");
if(i==0)
{ System.out.println("\t 没有异常事件");
return;
}
else if(i==1)
{ String str="abc";
int k;
k=Integer.parseInt(str);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -