java.util.IdentityHashMap.keySet() Method
Advertisements
Description
The keySet() method is used to get an identity-based set view of the keys contained in this map.
Declaration
Following is the declaration for java.util.IdentityHashMap.keySet() method.
public Set<K> keySet()
Parameters
NA
Return Value
The method call returns an identity-based set view of the keys contained in this map.
Exception
NA
Example
The following example shows the usage of java.util.IdentityHashMap.keySet()
package com.tutorialspoint;
import java.util.*;
public class IdentityHashMapDemo {
public static void main(String args[]) {
// create identity hash map
IdentityHashMap ihmap = new IdentityHashMap();
// populate the map
ihmap.put(1, "java");
ihmap.put(2, "util");
ihmap.put(3, "package");
// create a set view
Set nset=ihmap.keySet();
System.out.println("Set view is: " + nset);
}
}
Let us compile and run the above program, this will produce the following result.
Set view is: [2, 3, 1]