catchexception.java
来自「some example source of java,for beginner」· Java 代码 · 共 39 行
JAVA
39 行
package example8;public class CatchException { public static void a() throws MyException{ System.out.println("Throwing MyException from a()"); throw new MyException(); } public static void b() throws MyException{ System.out.println("Throwing MyException from b()"); throw new MyException("Originated in b()"); } public static void c() throws MyException{ System.out.println("Throwing MyException from c()"); throw new MyException("Originated in c()",47); } public static void main(String[] args) { try{ a(); } catch(MyException e){ e.getMessage(); } try{ b(); } catch(MyException e){ e.toString(); } try{ c(); } catch(MyException e){ e.printStackTrace(); System.out.println("error code:"+e.val()); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?