exceptiontest3.java
来自「Java就业的培训教程书籍」· Java 代码 · 共 33 行
JAVA
33 行
class customExcep extends Exception {
public customExcep() {}
public customExcep(String strObj) {
super(strObj);
}
}
public class ExceptionTest3 {
public static void exceptionThrow() throws customExcep {
System.out.println(
"Throwing Exception from exceptionThrow()");
throw new customExcep();
}
public static void anotherThrow() throws customExcep {
System.out.println(
"Throwing Exception from anotherThrow()");
throw new customExcep("Generated from anotherThrow()");
}
public static void main(String[] args) {
try {
System.out.println("Test one exception:");
exceptionThrow();
} catch(customExcep e) {
e.printStackTrace();
}
try {
System.out.println("Test another exception:");
anotherThrow();
} catch(customExcep e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?