NO.33 数组操作的两个常见小问题越界和空指针
2017-07-17 本文已影响0人
WXFA
数组索引越界异常(ArrayIndexOutOfBoundsException)
原因:当访问的数组中没有访问的索引时,会报这样的错: .ArrayIndexOutOfBoundsException

空指针异常(NullPointerException)
原因:当数组引用赋值为null后,数组已经不在指向堆内存了。而你还用数组名去访问元素,再去调用数组中的元素就会出现:java.lang.NullPointerException
