Some methods from Arrays class
Now, let’s have a talk about some methods from the Arrays class too since we have discussed quite arrays. Let’s discuss some static methods from the Arrays class that would help us in many ways, like sorting the array, searching through the array, filling the array with some particular value, etc. We will also see another way to print the array, which is basically printing the string representation of the array.
Some basic things that we are going to have here are –
- Printing string representation of an array.
- Sorting the array.
- comparison
- Searching in the array.
- Filling the array.
One thing to note – while we will be using the methods from the Arrays class, we have to import the Arrays class with the following instruction so that we can comfortably use the methods –
import java.util.Arrays;
First of all, let’s see one method, which helps us print the string representation of the array so that we can use it later while we will need to print the array.