equals(Object): This method is available in java.util.IdentityHashMap class of Java.
Syntax:
boolean java.util.IdentityHashMap.equals(Object o)
This method takes one argument. This method compares the specified object with this map for equality. Returns true if the given object is also a map and the two maps represent identical object-reference mappings.
Parameters: One parameter is required for this method.
o: object to be compared for equality with this map.
Returns: true if the specified object is equal to this map.
Exceptions: NA
Approach
Java
import java.util.IdentityHashMap;public class IdentityHashMapequals {public static void main(String args[]) {IdentityHashMap<String, Integer> identityHashMap =new IdentityHashMap<String, Integer>();identityHashMap.put("Java", 1);identityHashMap.put("Hello", 2);IdentityHashMap<String, Integer> o =new IdentityHashMap<String, Integer>();o.put("Java", 1);o.put("Hello", 2);System.out.println(identityHashMap.equals(o));}}
Output:
true
No comments:
Post a Comment