Javatpoint Logo
Javatpoint Logo

Java List equals() Method

The equals() method of List interface compares the specified object with this collection for equality. It returns a Boolean value true if both the lists have same elements and are of the same size.

Syntax

Parameters

The parameter 'o' represents the object to be compared for equality with this list.

Specified By

equals in interface Collection<E>

Overrides

This method overrides equals in class Object

Returns

The equals method returns a Boolean value 'true' if the specified object is equal to this list else it returns false.

Example 1

Test it Now

Output:

Both the lists are equal.
List  : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
List1 : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Example 2

Test it Now

Output:

Both the lists are unequal.
List : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
List1 : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Next TopicJava List





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA