exceptiondemo.java
来自「JAVA编程思想源代码 值得一下 很难找的」· Java 代码 · 共 28 行
JAVA
28 行
package chapter14;
public class ExceptionDemo {
public static void main(String[] args) {
boolean flag = true;
try {
int chu = Integer.parseInt(args[0]);
int num = 50;
System.out.println(num + "/" + chu + " is :" + num / chu);
} catch (ArithmeticException e) {
flag = false;
System.out.println("代码中出现 除以0 的错误");
} catch (ArrayIndexOutOfBoundsException e2) {
flag = false;
System.out.println("用户没有输入参数");
} finally {
if (flag == true)
System.out.println("程序正常结束");
else if (flag == false)
System.out.println("程序发生异常");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?