trycatchfinally.java~14~

来自「提供了常用的JAVA技术的示例」· JAVA~14~ 代码 · 共 42 行

JAVA~14~
42
字号
package TryCatchFinally;public class TryCatchFinally {    static void proc(int sel){        System.out.println("---------In Situation"+sel+"--------");        try{            if(sel==0){                System.out.println("no Exception caught");                return;            }            else if(sel==1){                int i=0;                int j=4/i;            }            else if(sel==2){                int A[]=new int[2];                A[10]=3;            }        }        catch(ArithmeticException e){            System.out.println("Catch "+e);        }        catch(ArrayIndexOutOfBoundsException e){            System.out.println("Catch "+e);            System.out.println("Catch "+e.hashCode());            System.out.println("Catch "+e.getClass());            System.out.println("Catch "+e.toString());        }        catch(Exception e){            System.out.println("Will not be executed");        }        finally{            System.out.println("in proc finally");        }    }    public static void main(String args[]){        proc(0);        proc(1);        proc(2);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?