File size: 621 Bytes
0284885 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | package Exception_package1;
public class Exception_demo2 {
public static void main(String[] args) {
/*
异常作用一:异常是用来查询bug的关键参考信息
异常作用二:异常可以作为方法内部的一种特殊返回值,以便通知调用者底层的执行情况
*/
//1、查询bug
Student[] arr = new Student[3];//null null null
//arr[0] = new Student();
String name = arr[0].getName();
System.out.println(name);
//2、特殊返回值
Student s1 = new Student();
s1.setAge(50);
}
}
|