The floorEntry() method of
NavigableMap interface in Java is used to return a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.
Syntax:
Map.Entry<K, V> floorEntry(K key)
Where, key is the key maintained by this map.
Parameters: key - the key
Return Value: It returns an entry with the greatest key less than or equal to key, or null if there is no such key.
Below programs illustrate the floorEntry() method in Java:
Program 1: When the key is integer.
Output:
The mapping with greatest key is : 2=two
Program 2: When the key is string.