melon.java
来自「金旭亮的java教案」· Java 代码 · 共 45 行
JAVA
45 行
import javax.swing.*;
class melon {
public static void main(String[] a)
{
int i=1, j=0, k;
// k=i/j;
try
{
k = i/j; // Causes division-by-zero exception
// throw new Exception("Hello.Exception");
}
catch (Exception e)
{
if (e instanceof ArithmeticException)
System.out.println("被0除");
else
{
System.out.println(e.getMessage());
System.out.println(e.getCause().getMessage());
}
}
catch ( ArithmeticException e)
{
System.out.println("被0除. "+ e.getMessage());
}
finally
{
JOptionPane.showConfirmDialog(null,"OK");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?