不明白这里为什么有异常?
class Student{
private int rollNo;
private String name;
public void setrollNo(int rollNo){
this.rollNo = rollNo;
}
public void setName(String name){
this.name = name;
}
public int getrollNo() {
return rollNo;
}
public String getName() {
return name;
}
public static void main(String args[]){
Student[] arrStudent = new Student[2];
try{
arrStudent[0].setrollNo(1001);
//arrStudent[1].setrollNo(1002);
}
catch(NullPointerException e1) {
System.out.println("#1Dealt it already!");
}
finally{
try{
System.out.println(arrStudent[0].getrollNo());
}
catch(NullPointerException e2) {
System.out.println("#2Dealt it already!");
}
}
}
}
e1,e2我做了处理,但我还是不明白为什么会有异常出现.