The pollFirstEntry() method of
NavigableMap interface in Java is used to remove and return a key-value mapping associated with the least key in this map, or null if the map is empty.
Syntax:
Map.Entry< K, V > pollFirstEntry()
Where, K is the type of key maintained by this map and V is the type of values mapped to the keys.
Parameters: This function does not accepts any parameter.
Return Value: It returns a key-value mapping associated with the least key after removing it from this map, or null if the map is empty.
Below programs illustrate the pollFirstEntry() method in Java:
Program 1: When the key is integer.
Output:
First removed key-value from the map : 2=two
Program 2: When the key is string.