📄 myexception.java
字号:
import java.lang.Exception;public class MyException extends Exception { private int attribute; public MyException(int i) { attribute = i; } public String toString() { return "MyException[" + attribute + "]"; }}class DemonException { static void compare(int a) throws MyException { System.out.println("called compare(" + a + ")"); if(a > 5) { throw new MyException(a); } System.out.println("Normal Exit"); } public static void main(String[] args) { try { compare(3); compare(15); } catch(MyException e) { System.out.println("Caught " + e); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -