Open In App

ConcurrentSkipListMap equals() method in Java with Examples

Improve
Improve
Like Article
Like
Save
Share
Report

The equals() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which to check the equality of this Map object with the specified object. The method returns true if the given object is also a map of the previous one and the two maps have the same mappings.

Syntax:

public boolean equals(Object ob)

Parameter: The function accepts a single mandatory parameter ob which specifies object to be compared for equality with this map.

Return Value: The function returns true if the specified object is equal to this map.

Below programs illustrate the above method:

Program 1:




// Java Program Demonstrate equals()
// method of ConcurrentSkipListMap
  
import java.util.concurrent.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        // Initializing the map
        ConcurrentSkipListMap<Integer, Integer>
            mpp = new ConcurrentSkipListMap<Integer,
                                            Integer>();
  
        // adding elements in map
        for (int i = 1; i <= 5; i++)
            mpp.put(i, i);
  
        // equals operation on map
        System.out.println(mpp.equals(4));
    }
}


Output:

false

Program 2:




// Java Program Demonstrate equals()
// method of ConcurrentSkipListMap
  
import java.util.concurrent.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        // Initializing the map
        ConcurrentSkipListMap<Integer, Integer>
            mpp = new ConcurrentSkipListMap<Integer,
                                            Integer>();
  
        // adding elements in map
        for (int i = 1; i <= 5; i++)
            mpp.put(i, i);
  
        // equals operation on map
        System.out.println(mpp.equals(3));
    }
}


Output:

false

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListMap.html#equals-java.lang.Object-



Last Updated : 14 Feb, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads