exception

package com.pekall.xing;

public class ExceptionTest {
    
    public void fun() throws Exception{
       
//        try {
            throw new TestException();
//        } catch (Exception e) {
//            // TODO: handle exception
//            System.out.print("1");
//       //     e.printStackTrace();
//        }
    }
    
    public void g(){
            try {
                
            fun();
    
            } catch (Exception e) {
                // TODO: handle exception
                System.out.print("2");
            }
        };
    public static void main(String args[]) {
        ExceptionTest test = new ExceptionTest();
        test.g();
    }

}


//    2



package com.pekall.xing;

public class ExceptionTest {
    
    public void fun(){
       
        try {
            throw new TestException();
        } catch (Exception e) {
            // TODO: handle exception
            System.out.print("1");
            e.printStackTrace();
        }
    }
    
    public void g(){
            try {
                
            fun();
    
            } catch (Exception e) {
                // TODO: handle exception
                System.out.print("2");
            }
        };
    public static void main(String args[]) {
        ExceptionTest test = new ExceptionTest();
        test.g();
    }
}


//1


你可能感兴趣的:(exception,String,Class,fun)