exception2.java
来自「课本异常处理实例。各种异常处理」· Java 代码 · 共 24 行
JAVA
24 行
//捕获算术异常Arithmetic Exception
public class Exception2
{
public static void main(String args[])
{
try
{
int x, y;
x=15;
y=0;
System.out.println(x/y);//注意!!!
System.out.println("Computing successfully!");
}
catch (ArithmeticException e)
{
System.out.println(" ArithmeticException catched !" );
System.out.println("Exception message:"+e.toString());//返回异常的信息
}
finally
{
System.out.println("Finally block.");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?