Home » Java Collection equals() Method with Examples

Java Collection equals() Method with Examples

by Online Tutorials Library

Java Collection equals() Method

The equals() method of Java Collection Interface compares the specified object with this collection for equality.

Syntax

Parameters

The parameter ‘o’ represents the object to be compared for equality with this collection.

Overrides

This method overrides equals in class Object

Return

The equals method returns Boolean value ‘true’ if the specified object is equal to this collection else it returns false.

Example 1

Test it Now

Output:

true  

Example 2

Test it Now

Output:

Equals methods will return : false  
Next TopicJava Collection

You may also like