Review 1 basis

Defined array: An array is a fixed-length

Defined in three ways:

int[] arr = new int[3];
int[] arr = new int[]{1,2,3,4,5};
int[] arr = {1,2,3,4,5};
Note: the length of said array is a length attribute; string length () method; is set size () method.
 
 

Two common abnormal array: array bounds: ArrayIndexOutOfBoundsException null pointer exception: NullPointerException

Manually sorted array an idea: First define the maximum array index value, through the array of 0, compared with the maximum value; if the value of the array is greater than the maximum value, the maximum value will be replaced with a new array values; this has been traversed , has been compared with the constantly changing maximum. Final result is the maximum value of the array.

The simplest way: by Arrays.sort (array parameters);

 

 

 

Guess you like

Origin www.cnblogs.com/mason117/p/11029609.html