Array tools and common exceptions

Disclaimer: All my articles are the compilation of online teaching videos, including Mad God Talk, Shang Silicon Valley, Dark Horse Programmer, etc., used as reference materials, without any commercial use, please refer to the majority of netizens, please do not spray ,Thank you.
1. Use of Arrays tool class
Java.util.Arrays class is the tool class for manipulating arrays, including various methods for manipulating arrays (such as sorting and searching).
Array tools and common exceptions
Examples of Sort() methods:
Array tools and common exceptions
2. Common in the use of arrays Exception
1. Array IndexOutOfBoundsException (ArrayIndexOutOfBoundsException)
int[] arr = new int[2];
System.out.println(arr[2]);
System.out.pirntln(arr[-1]);
Access to the array Occurs when a subscript does not exist in the.
2, NullPointerException (NullPointerException)
int[] arr = null;
System.out.println(arr[0]); The
arr reference does not point to the entity, but the element in the entity is to be manipulated.

Guess you like

Origin blog.51cto.com/12859164/2545254