Array class

The java.util.Arrays class contains various static methods for sorting, searching, comparing and filling array elements. These methods are overloaded for all primitive types.

1. public static void sort(Object[] arr)

It sorts the specified array of objects into an ascending order.

2. public static int binarySearch(Object[] arr, Object key)

It searches the sorted array for a specified key using binary search algorithm. This method returns the index of the searched key, if it is found in the list; otherwise, it returns -1.

3. public static void arrayCopy (Object src , int srcPos , Object dest , int destPos , int length)

It copies the values from one array to another array.

4. public static boolean equals (dataType[] arr, dataType[] arr2)

It returns true if the two specified arrays are equal to one another, otherwise it returns false.

5. public static void fill(int[] arr, int value)

It assigns the specified int value to each element of the array.