Lobachesqui
0
Q:

TreeMap pollLastEntry() method in java

import java.util.TreeMap;
public class TreeMapPollFirstEntryMethodExample
{
   public static void main(String[] args)
   {
      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
      tm.put(63, "yellow");
      tm.put(95, "red");
      tm.put(96, "green");
      tm.put(21, "violet");
      tm.put(28, "blue");
      System.out.println("TreeMap before using pollFirstEntry() method: " + tm);
      System.out.println("Value is: " + tm.pollFirstEntry());
      System.out.println("TreeMap after using pollFirstEntry() method: " + tm);
   }
}
1
import java.util.TreeMap;
public class TreeMapPollLastEntryMethodExample
{
   public static void main(String[] args)
   {
      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
      tm.put(63, "yellow");
      tm.put(95, "red");
      tm.put(96, "green");
      tm.put(21, "violet");
      tm.put(28, "blue");
      System.out.println("TreeMap before using pollLastEntry() method: " + tm);
      System.out.println("Value is: " + tm.pollLastEntry());
      System.out.println("TreeMap after using pollLastEntry() method: " + tm);
   }
}
1

New to Communities?

Join the community