?? printexceptionwarning.java
字號(hào):
// 輸出異常信息。
class DemonException {
static void generateException() {
int nums[] = new int[5];
System.out.println("Before exception is generated.");
// 產(chǎn)生數(shù)組越界異常
nums[10] = 20;
System.out.println("this won't be displayed");
}
}
class PrintExceptionWarning {
public static void main(String args[]) {
try {
DemonException.generateException();
}
catch (ArrayIndexOutOfBoundsException e) {
// 捕捉異常
System.out.println("Standard message is: ");
System.out.println(e);
System.out.println("\nDescription for the exception is: ");
System.out.println(e.getMessage());
System.out.println("\nStack trace: ");
e.printStackTrace(); //輸出異常信息
}
System.out.println("\nAfter catch statement.");
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -