📄 exce2.java
字号:
//在方法中定义异常
import java.lang.*;
public class Exce2{
public static void main(String args[])
{
try
{
System.out.println(num(0));
}
catch(ArithmeticException e1)
{
System.out.println(e1.getMessage());
}
}
public static int num(int i) throws ArithmeticException
{
if (i==0)
{
ArithmeticException e=new ArithmeticException("除数不能为0");
throw e;
}
return(10/i);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -