return treemap entry set java code example
Example 1: 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>();
tm.put("mango", 56);
tm.put("apple", 28);
tm.put("banana", 35);
tm.put("pineapple", 73);
tm.put("orange", 61);
System.out.println("Given TreeMap is: " + tm);
System.out.println("set view is: " + tm.entrySet());
}
}
Example 2: TreeMap entrySet() method in java
import java.util.TreeMap;
public class TreeMapEntrySetMethodExample
{
public static void main(String[] args)
{
TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
tm.put(56, "mango");
tm.put(28, "apple");
tm.put(35, "banana");
tm.put(73, "pineapple");
tm.put(61, "orange");
System.out.println("Given TreeMap is: " + tm);
System.out.println("set view is: " + tm.entrySet());
}
}