TreeMap entrySet() method in java
example to map integer values to String keys
import java.util.TreeMap;
public class TreeMapEntrySetMethodExample
{
public static void main(String[] args)
{
TreeMap<String, Integer> tm = new TreeMap<String, Integer>();
// map Integer values to String keys
tm.put("mango", 56);
tm.put("apple", 28);
tm.put("banana", 35);
tm.put("pineapple", 73);
tm.put("orange", 61);
// printing the TreeMap
System.out.println("Given TreeMap is: " + tm);
// use entrySet() to get set view
System.out.println("set view is: " + tm.entrySet());
}
}