TreeMap ceilingKey() method in java
example of TreeMap ceilingKey(K key) method when it returns null
import java.util.NavigableMap;
import java.util.TreeMap;
public class TreeMapCeilingkeyDemo
{
public static void main(String[] args)
{
NavigableMap<Integer, String> nm = new TreeMap<Integer, String>();
nm.put(10, "apple");
nm.put(20, "banana");
nm.put(30, "cherry");
nm.put(40, "fig");
nm.put(60, "grape");
nm.put(70, "kiwifruit");
// 200 is not present in map
// or any key greater than 200
// hence returns null
System.out.println("Ceiling key for 200: " + nm.ceilingKey(200));
}
}