异常捕获易错题目

    技术2022-05-20  39

    public class XX { public static void main(String[] args) { // TODO Auto-generated method stub try { new Exception(); //new Exception(); } catch(Exception e) { System.out.println("Caught in main()"); } System.out.println("nothing"); } }  

    结果是:nothing

     

    public class YY { public static void main(String[] args) throws Exception { try { throw new Exception(); }catch(Exception e){ System.out.println("Caught in main()"); } System.out.println("nothing"); } }  

    结果是:

    Caught in main()

    nothing


    最新回复(0)