How do I use Map class of Java to define a key->value set?
A Map is an interface…it defines methods that any class that wants to implement a Map must use, but it doesn’t provide any concrete implementation for adding key value sets. You want to instantiate or extend one of the Java classes that implement the Map interface: Hashtable (a common one), HashMap, TreeMap, WeakHashMap, etc. Which one you use depends on your needs: some permit null entries (HashMap), some permit synchronization when working with multiple threads (HashMap), others don’t, some will result in sorted keys (TreeMap), etc. –> You get the point -> The Java API documentation provided in sources can give you more information on the different maps and help you determine which to use. Once you pick one, you simply create an instance of one of the provided classes, or the one you’ve extended… ie. Hashtable exTable = new HashTable(); and you can use the put and get methods to define(enter) key value sets, and retrieve them. ie. exTable.put(“eggs”,12); exTable.put(“bread”,1);