keySet(): This method is available in java.util.IdentityHashMap class of Java.
Syntax:
Set<K> java.util.IdentityHashMap.keySet()
This method returns an identity-based set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.
Parameters: NA
Returns: an identity-based set view of the keys contained in this map.
Exceptions: NA
Approach
Java
import java.util.IdentityHashMap;public class IdentityHashMapkeySet {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.keySet());}}
Output:
[Java, Hello]
No comments:
Post a Comment