IdentityHashMap entrySet() in Java

entrySet(): This method is available in java.util.IdentityHashMap class of Java..

Syntax:

Set<Entry<K, V>> java.util.IdentityHashMap.entrySet()

This method returns a Set view of the mappings contained in this map.Each element in the returned set is a reference-equality-based Map.Entry.

Parameters: NA

Returns: a set view of the identity mappings contained in this map.

Exceptions: NA

Approach

Java

import java.util.IdentityHashMap;

public class IdentityHashMapentrySet {

    public static void main(String args[]) {

        IdentityHashMap<String, Integer> identityHashMap =
new IdentityHashMap<String, Integer>();

        identityHashMap.put("Java", 1);
        identityHashMap.put("Hello", 2);

        System.out.println(identityHashMap.entrySet());
    }

}

Output:

[Java=1, Hello=2]


No comments:

Post a Comment