Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Java Arrays. equals() Method?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___[] cars = {"Volvo", "BMW", "Tesla"};3Order
Put the learning moves in the order that makes the concept easiest to apply.
The equals() method checks whether two arrays are equal.
Definition and Usage
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
| Parameter | Description |
|---|---|
| array1 | Required. The array to compare with array2 |
| array2 | Required. 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. |
|---|