treemap entryset 28 29 method in java

Solutions on MaxInterview for treemap entryset 28 29 method in java by the best coders in the world

showing results for - "treemap entryset 28 29 method in java"
Raphael
05 Apr 2018
1example to map integer values to String keys
2import java.util.TreeMap;
3public class TreeMapEntrySetMethodExample
4{
5   public static void main(String[] args)
6   {
7      TreeMap<String, Integer> tm = new TreeMap<String, Integer>();
8      // map Integer values to String keys
9      tm.put("mango", 56);
10      tm.put("apple", 28);
11      tm.put("banana", 35);
12      tm.put("pineapple", 73);
13      tm.put("orange", 61);
14      // printing the TreeMap
15      System.out.println("Given TreeMap is: " + tm);
16      // use entrySet() to get set view
17      System.out.println("set view is: " + tm.entrySet());
18   }
19}
Christian
01 Oct 2020
1import java.util.TreeMap;
2public class TreeMapEntrySetMethodExample
3{
4   public static void main(String[] args)
5   {
6      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
7      // map String values to Integer keys
8      tm.put(56, "mango");
9      tm.put(28, "apple");
10      tm.put(35, "banana");
11      tm.put(73, "pineapple");
12      tm.put(61, "orange");
13      // printing the TreeMap
14      System.out.println("Given TreeMap is: " + tm);
15      // use entrySet() to get set view
16      System.out.println("set view is: " + tm.entrySet());
17   }
18}