i=3时
catch 过后i=-1
然后又执行i++
结果又得到i=0
重新循环

解决方案 »

  1.   

    如上所说,i=3时,超出下标,抛出异常
    i<3
      

  2.   

    public class HelloWorld {
       public static void main(String args[]){
       int i=0;
       String greetings[] ={
       "Hello world!",
       "No,I mean it!",
       "HELLO WORLD!!" 
        };  
       while(i<4){
         try{
         System.out.println(greetings[i]);
         }catch(ArrayIndexOutOfBoundsException e){
          System.out.println("Re-setting Index Value");
          
          }finally{
             System.out.println("This is always printed");
             }
         i++;
         }
      }
    }这样就可以!谢谢!