exceptiondemo.java
来自「JAVA 2应用开发指南」· Java 代码 · 共 26 行
JAVA
26 行
//ExceptionDemo.java
public class ExceptionDemo {
public static void main(String[ ] args) {
int i=0;
try {
i = Integer.parseInt(args[0]);
// possible ArithmeticException
}
catch (NumberFormatException e) {
// print an error message
System.err.println("Usage: java HelloThere repeat_count" );
return;
}
catch (ArrayIndexOutOfBoundsException e) {
// pick a default value
System.out.println("ArrayIndexOutOfBoundsException");
i = 2;
}
for (int a = 0; a<i; a++) {
System.out.println("Hello");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?