IdentityHashMap entrySet Example
IdentityHashMap class entrySet example. This example shows you how to use entrySet method.
IdentityHashMap class entrySet example.public Set entrySet() Returns a Set view of the mappings contained in this map. Each element in the returned set is a reference-equality-based Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.
Here is the code
/**
* @ # EntrySet.java
* A class repersenting use to entrySet method
* of IdentityHashMap class in java.util package
* version 26 May 2008
* author Rose India
*/
import java.util.*;
public class EntrySet {
public static void main(String args[]) {
IdentityHashMap map = new IdentityHashMap();
//Add the mapping into the map
map.put(1, "A");
map.put(2, "A");
map.put(3, "B");
System.out.println("Map " + map);
//A Set view of the mappings contained in this map.
Set set = map.entrySet();
System.out.println("set " + set);
}
} |
Output
Map {3=B, 2=A, 1=A}
set [3=B, 2=A, 1=A] |
|