public class ExceptionDemo {
public static void main(String[] args) throws Exception {
int [] arr={};
int i= getArray(arr);
System.out.println(i);
}
public static int getArray(int[] arr) throws Exception{
if(arr==null){
throw new Exception("传递数组不存在");
}
if (arr.length==0) {
throw new Exception("数组没有元素");
}
return arr[arr.length-1];
}
}