欢迎来到萧静默的博客

书山有路勤为径,学海无涯苦作舟。

Java-异常处理-throws

package Exception;

public class ExceptionDemo {
    public static void main(String[] args) throws Exception {
        int[] arr = {};
        fun(arr);
    }

    public static void fun(int[] arr) throws Exception {
        if (arr == null)
        {
            throw new Exception("没有传递数组 ");

        }
        if (arr.length == 0)
        {
            throw new Exception("传递的数组为空");
        }

        int[] arry = arr;
        int i = arr[arr.length - 1];

    }
}

 

posted @ 2020-08-18 11:41  萧静默  阅读(114)  评论(0编辑  收藏  举报