?? ex7(1).java
字號(hào):
// exceptions/Ex7.java
// TIJ4 Chapter Exceptions, Exercise 7, page 456
// Modify Exercise 3 so that the catch clause logs the result.
import java.util.logging.*;
import java.io.*;
public class Ex7 {
private static int[] ia = new int[2];
private static Logger logger = Logger.getLogger("Ex7 Exceptions");
static void logException(Exception e) { // Exception e argument
StringWriter trace = new StringWriter();
e.printStackTrace(new PrintWriter(trace));
logger.severe(trace.toString());
}
public static void main(String[] args) {
try {
ia[2] = 3;
} catch(ArrayIndexOutOfBoundsException e) {
System.err.println(
"Caught ArrayIndexOutOfBoundsException");
e.printStackTrace();
// call logging method:
logException(e);
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -