Two common minor problems of cross-border and array operations null pointer
Others
2019-07-14 19:17:54
views: null
Two common minor problems of cross-border and array operations null pointer:
- a: ArrayIndexOutOfBoundsException: Array index out of bounds abnormal
- The reason: you visit the index does not exist.
- int[] arr = new int[3];
- System.out.println(arr[3]);
- b: NullPointerException: null pointer exception
- The reason: no longer pointing to an array of heap memory. And you also use to access the elements of an array name.
- int[] arr = {11,12,13};
- scar = null;
- System.out.println(arr[0]);
Origin www.cnblogs.com/Wangzui1127/p/11184589.html