class thro
{
public static void main(String args[])
{
try
{
try
{
throw new ArrayIndexOutOfBoundsException("OOB"); 
}
catch(ArrayIndexOutOfBoundsException f)
{
System.out.println("捕捉内部的Exception");
throw f;
} }catch(ArrayIndexOutOfBoundsException f)
{
System.out.println("再捕捉Exception"+f);
}
}
}

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【sure2003】截止到2008-07-07 10:43:40的历史汇总数据(不包括此帖):
    发帖的总数量:203                      发帖的总分数:9217                     
    结贴的总数量:202                      结贴的总分数:9187                     
    无满意结贴数:2                        无满意结贴分:50                       
    未结的帖子数:1                        未结的总分数:30                       
    结贴的百分比:99.51 %               结分的百分比:99.67 %                  
    无满意结贴率:0.99  %               无满意结分率:0.54  %                  
    值得尊敬
      

  2.   

    class thro
    {
        public static void main(String args[])
        {
            try
            {
                try
                {
                    throw new ArrayIndexOutOfBoundsException("OOB"); //直接抛出一个越界的运行时异常
                }
                catch(ArrayIndexOutOfBoundsException f)//这里捕获越界异常
                {
                    System.out.println("捕捉内部的Exception");//打印异常
                    throw f;// 这里继续抛出异常
                }        }catch(ArrayIndexOutOfBoundsException f)//外层再次捕获异常
            {
                    System.out.println("再捕捉Exception"+f);//打印异常
            }
        }
    }
      

  3.   

    不同上
    //类名,不符合规范,首字母未大写
    class thro
    {
        //类的主方法,正确
        public static void main(String args[])
        {
            try
            {
                try
                {
                    // 直接抛出一个越界的运行时异常
                    throw new ArrayIndexOutOfBoundsException("OOB");
                }
                // 这里捕获越界异常
                catch(ArrayIndexOutOfBoundsException f)
                {
                    // 打印异常
                    System.out.println("捕捉内部的Exception");
                    // 这里继续抛出异常
                    throw f;
                }
            }
            // 外层再次捕获异常
            catch(ArrayIndexOutOfBoundsException f)
            {
                // 打印异常
                System.out.println("再捕捉Exception" + f);
            }
        }
    }
      

  4.   

    class thro {
      public static void main(String args[]) {
        try {
          try {
            // 这里手工抛出了异常
            throw new ArrayIndexOutOfBoundsException("OOB");
          } catch (ArrayIndexOutOfBoundsException f) {
            // 这里捕获了,如果是父类类异常,比如Exception 也能捕获
            System.out.println("捕捉内部的Exception");
            // 这里你又抛出去了
            throw f;
          }
        } catch (ArrayIndexOutOfBoundsException f) {
          // 还是同样的异常,应该换成Exception 看看,呵呵
          System.out.println("再捕捉Exception" + f);
        }
      }
    }
      

  5.   

    这个主要是体现了Exception层层抛出的概念
      

  6.   

    class ThrowStatDemo {
    //class thro {  //类名按规范应该是首字符大写的名词或名词词组(其余单词首字符也要大写) public static void main(String[] args) {
    //Java 中提倡将 [] 放数组元素类型后面,能体现出 args 本质上是个对象变量
    try {
    try {
    throw new ArrayIndexOutOfBoundsException("OOB");
    //手动创建异常对象并用 throw 语句抛出
    } catch (ArrayIndexOutOfBoundsException f) {
    //此处 f 的作用域是本 catch 块,不会跟下面的 f 冲突
    System.out.println("捕捉内部的Exception");
    //捕获到上面抛出的异常并打印出 "捕捉内部的Exception"
    throw f;
    //再次将捕到的异常上抛 *
    }
    } catch (ArrayIndexOutOfBoundsException f) {
    System.out.println("再捕捉Exception" + f);
    //捕获到 * 处抛出的异常并打印出
    //"再捕捉Exception" + "java.lang.ArrayIndexOutOfBoundsException: OOB"
    //因为异常类 ArrayIndexOutOfBoundsException 的 toString 被设计成返回
    //异常类带包名限定的类名加 : 加 new 它时给的异常描述信息 OOB。
    }
    }}
      

  7.   

    ArrayIndexOutOfBoundsException
    这个是什么异常.
    为什么没有任何提示,会产生这种异常对象...
      

  8.   


    这是运行时异常,public class ArrayIndexOutOfBoundsException
    extends IndexOutOfBoundsException表示用非法数组下标访问数组时抛出的异常信息。如果下标为负或大于等于数组尺寸则为非法下标。 
    运行时才能发现此异常的。
    import java.util.ArrayList;class thro {
    public static void main(String args[]) {
    ArrayList<String> list=new ArrayList<String>();
    System.out.println(list.get(-1));//运行时抛出java.lang.ArrayIndexOutOfBoundsException
    }
    }