NavigableMap: pollLastEntry()

Map.Entry<K,V> pollLastEntry()
Removes and returns a key-value mapping associated with the greatest key in this map.
 
import java.util.NavigableMap;
import java.util.TreeMap;
import java.util.Map.Entry;

public class Main {
  public static void main(String[] args) {
    NavigableMap<Integer, String> map = new TreeMap<Integer, String>();
    map.put(2, "two");
    map.put(1, "one");
    map.put(3, "three");
    System.out.println("Original map: " + map + "\n");

    Entry firstEntry = map.pollFirstEntry();
    System.out.println("First entry: " + firstEntry);
    System.out.println("After polling the first entry: " + map + "\n");

    Entry lastEntry = map.pollLastEntry();
    System.out.println("Last entry:" + lastEntry);
    System.out.println("After polling last entry:" + map);
  }
}
  
Home 
  Java Book 
    Collection  

NavigableMap:
  1. NavigableMap
  2. NavigableMap: ceilingKey(T key)
  3. NavigableMap: floorKey(T key)
  4. NavigableMap: higherKey(String key)
  5. NavigableMap: lastEntry()
  6. NavigableMap: lowerKey(T key)
  7. NavigableMap: navigableKeySet()
  8. NavigableMap: pollFirstEntry()
  9. NavigableMap: pollLastEntry()