This Java Example shows how to Get ceilingEntry in Java NavigableMap object
Get ceilingEntry(K key) in Java NavigableMap Example
This Java Example shows how to Get ceilingEntry in Java NavigableMap
object. To get an ceiling Entry of NavigableMap We use Map.Entry ceilingEntry(K key)
method. This method returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such
key, from NavigableMap object respectively.
Example: CeilingEntryNavigableMap.java
package devmanuals.com; import java.util.*; public class CeilingEntryNavigableMap { public static void main(String[] args) { NavigableMap<Integer, String> Nmap = new TreeMap<Integer, String>(); Nmap.put(2, "two"); Nmap.put(1, "one"); Nmap.put(3, "three"); Nmap.put(6, "six"); Nmap.put(5, "five"); System.out.println("The ceiling entry of 4 is : " + Nmap.ceilingEntry(4)); System.out.println("The ceiling entry of 5 is : " + Nmap.ceilingEntry(5)); } }
Output:
The ceiling entry of 4 is : 5=five
The ceiling entry of 5 is : 5=five |
[ 0 ] Comments