Java学习-动手动脑4

异常处理

public class SystemExitAndFinally {


    public static void main(String[] args) {

        try {


            System.out.println("in main");

            throw new Exception("Exception is thrown in main");

            //System.exit(0);


        } catch (Exception e) {

            System.out.println(e.getMessage());

            System.exit(0);

        } finally {

            System.out.println("in finally");

        }

    }


}

 

posted @ 2021-12-09 13:30  Acholl  阅读(21)  评论(0)    收藏  举报