Java examples for Collection Framework:TreeMap
how to check if TreeMap object contains a particular key using containsKey method of TreeMap class
import java.util.TreeMap; public class Main { public static void main(String[] args) { // ww w.j av a 2s .c o m //create TreeMap object TreeMap treeMap = new TreeMap(); //add key value pairs to TreeMap treeMap.put("1","One"); treeMap.put("2","Two"); treeMap.put("3","Three"); boolean blnExists = treeMap.containsKey("1"); System.out.println("1 exists in TreeMap ? : " + blnExists); } }