The Arrays class is a tool class provided in Java, in the Java.util package. The class contains methods for manipulating arrays directly, such as sorting, searching, and so on (for classes and methods), which are explained in detail in a later section.
Common methods in Arrays:
1. Sorting
Syntax: arrays.sort (array name);
You can use the sort () method to sort the array, as long as the array name is placed in the parentheses of the sort () method, which you can sort (in ascending order), such as:
Operation Result:
2. Converting an array to a string
Syntax: arrays.tostring (array name);
You can use the ToString () method to convert an array to a string that joins multiple array elements sequentially, separated by commas and spaces between multiple elements, such as:
The result of the operation is:
Elements in the output array nums: [25,7,126,53,14,86]
The Arrays class also provides many other ways to manipulate the array here without listing them.
Using the Arrays class to manipulate arrays in Java