How do I compare if two arrays are equal?
Category: java.util, viewed: 5K time(s).
Using Arrays.equals() methods we can compare if two arrays are equal. Two arrays are considered to be equal if their length, each element in both arrays are equal and in the same order to one another.
The code below give you an example:
The Arrays.equals() can be used to compare array of any primitive data type and array of Object. If you run this example you will have a result as follow:
true false