declareexception.java~2~

来自「java2参考大全上的例子的源码和自己的理解.」· JAVA~2~ 代码 · 共 37 行

JAVA~2~
37
字号
package declareexception;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author not attributable * @version 1.0 */class DeclareException {static void Proc(int sel) throws//原来没有static,自己加的     ArithmeticException,     ArrayIndexOutOfBoundsException {   System.out.println("In Situation" + sel);   if (sel == 0) {     System.out.println("no Exception caught");     return;   }   else if (sel == 1) {     int iArray[] = new int[4];     iArray[10] = 3;   } } public static void main(String args[]) { //写成public static void main(String args[])会出错,不知为什么??   try {     Proc(0);     Proc(1);   }   catch (ArrayIndexOutOfBoundsException e) {     System.out.println("Catch " + e);   } }}

⌨️ 快捷键说明

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