Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

equals()

 

Example

Determine whether two arrays are identical.

String[] cars = {“Volvo”, “BMW”, “Tesla”};

String[] cars2 = {“Volvo”, “BMW”, “Tesla”};

System.out.println(Arrays.equals(cars, cars2));

Definition and Usage

The equals() method verifies if two arrays are equivalent.

Note: Two arrays are considered equal if they possess identical elements arranged in the same order.

Syntax

Arrays.compare(array1, array2)

Parameter Values

Parameter

Description

array1

Necessary: Rephrase the array for comparison against array2.

array2

Essential: Rephrase the array intended for comparison with array1.

Technical Details

Returns:

Returns true if the arrays are identical.


Returns false if the arrays are not identical.