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];

    }
}

原文地址:https://www.cnblogs.com/BruceKing/p/13522642.html