- 一级目录
- 二级目录
- 基础API
- 数组下标越界异常
- 空指针异常 NullPointException
Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException:
Index 5 out of bounds for length 5
int[] from = {1,2,3,4,5};//数组一旦创建,长度不可改变
System.out.println("单独打印数组元素查看"+from[5]);
空指针异常 NullPointException
public static void main (String[] args){
//创建客户对象
Customer c = new Customer () ;
//访问这个客户的id
System.out.println(c.id); // 0
//重新给id赋值
c.id=9521;//终身代号
System.out.println("客户的id是="+c.id);
c = null;
System.out.println(c.id); //NullPointException, eg, 手中气球对象飞走了
}
class Customer{
//客中id
intid;//成员变量中的实例变量,应该先创建对象,然后通过引用."的方式访问。
}



