Java Arrays class is a utility class provided by Java to manipulate arrays. It contains various methods to sort the array, search the array and fill the array with specified elements.
The Arrays class is contained in the java.util package, so you have to import java.util.Arrays class to use it in the code.
Arrays class also provides asList method which allows us to use an array as a List. This method returns a fixed sized List backed by the original array.
Here are some of the methods of Java Arrays class which are very useful.
The static sort method allows an array to be sorted in ascending order or using a custom comparator.
The static binarySearch method allows us to search an element in an array using binary search algorithm.
The static fill method allows us to fill an array with the specified element.
The static equals method allows us to compare two arrays and check if they are equal or not.
The static deepEquals method allows us to deeply compare two arrays.
The static copyOf method allows us to copy elements of an array to another array.
The static asList method allows us to get List view of an array.
Below given are some Java Arrays class examples which uses various methods provided by the Arrays class.