bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Arrays. equals() Method

❮ Arrays Methods

Example

String[] cars = {"Volvo", "BMW", "Tesla"};
String[] cars2 = {"Volvo", "BMW", "Tesla"};
System.out.println(Arrays.equals(cars, cars2));

Definition and Usage

The equals() method checks whether two arrays are equal.

Note

Two arrays are consided equal if they share the same elements in the same order.

Syntax

Arrays.compare( array1 , array2 )

Parameter Values

ParameterDescription
array1Required. The array to compare with array2
array2Required. The array to be compared with array1

Technical Details

Returns:Returns true if the arrays are equal. Returns false if the arrays are not equal.

Previous

Java Arrays. compare() Method

Next

Java Arrays. sort() Method