Java NavigableMap remove element by key value range
import java.util.NavigableMap; import java.util.TreeMap; public class Main { public static void main(String[] args) { NavigableMap<Integer, String> map = new TreeMap<Integer, String>(); map.put(1, "CSS"); map.put(2, "HTML"); map.put(3, "Java"); map.put(4, "Javascript"); map.put(5, "SQL"); System.out.println(map);/*from w w w . ja v a 2s.c o m*/ map.subMap(1, false, 3, false).clear(); System.out.println(map); } }