Answers for "TreeMap pollFirstEntry() method in java"

2

TreeMap pollFirstEntry() 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);
   }
}
Posted by: Guest on October-28-2020
2

TreeMap pollLastEntry() method in java

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);
   }
}
Posted by: Guest on October-28-2020

Code answers related to "TreeMap pollFirstEntry() method in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language