本帖最后由 陈虹旭 于 2012-10-5 14:02 编辑  
 
    class ZiException extends Exception 
    { 
         ZiException(String message) 
         { 
               super(message); 
               this.getMessage(); 
         } 
    } 
    class Demo  
    { 
         public void method()throws Exception 
         { 
              try 
              { 
                   System.out.println("hehe"); 
              } 
              finally 
              { 
                   try 
                   { 
                        throw new ZiException("wuwu"); 
                   } 
                   catch(Exception e) 
                   { 
                        try 
                        { 
                             throw e; 
                        } 
                        finally 
                        { 
                             try 
                             { 
                                  System.out.println("heihei"); 
                             } 
                             finally 
                             { 
                                  System.out.println("huhu"); 
                             } 
                        } 
                   }   
              } 
   
         } 
    } 
    class ExceptionDemo6  
    { 
         public static void main(String[] args) 
         { 
              Demo d = new Demo(); 
              try 
              { 
                   d.method(); 
              } 
              catch (Exception e) 
              { 
                   System.out.println(e.toString()); 
                   System.out.println("voer"); 
              } 
   
         } 
    } 
 
 
老师在讲异常处理的时候,在try、catch、finally中的嵌套和格式上讲的不是很详细,所以在老师的程序基础上又添加了一些嵌套来说明一些问题。 
我想还算综合些吧,你能在不用编辑器的情况下: 
1.这个程序能编译通过吗? 
2.如果可以编译通过,运行结果是什么? 
3.这个小程序都涉及到了那些方面的知识?能得到一些怎样的结论? 
 
本人新人,能力有限,望高手看到不要喷水,共同学习共同促进... 
 
 
 |