exception中finally的使用

package com.te.exp;

/**
 * finally 的使用
 */
public class StudyExcep {
    public static void main(String[] args) {
        try {
            int[] arr = new int[3];
            arr[3] = 100;
            System.out.println("资源释放了。。。。");
        }catch (Exception e){
            e.printStackTrace();
            System.out.println("报错了 ");
        }finally {
            System.out.println("无论结果如何,资源一定要释放");
        }
    }
}
posted @ 2022-11-02 20:49  竹石2020  阅读(15)  评论(0编辑  收藏  举报