The Java Platform Java Runtime Environment Data Types Control Statemets Methods Arrays Classes and Objects Inheritance Constructor Interface Packages & Access Modifiers Java Collections Framework![]() What are Collections![]() The Java Collections Framework![]() Benefits![]() Collection hierarchy![]() The Collection Interface![]() Types of Collection![]() Iterators![]() Using Set![]() Using Map![]() Example | Using Map Map map = new HashMap(); // instantiate a concrete map
...
map.put(key, val); // insert a key-value pair
...
// get the value associated with key
Object val = map.get(key);
map.remove(key); // remove a key-value pair
if (map.containsValue(val)) { ... }
if (map.containsKey(key)) { ... }
Set keys = map.keySet(); // get the set of keys
// iterate through the set of keys
Iterator iter = keys.iterator();
while (iter.hasNext()) {
Object key = iter.next();
Object val = map.get(key);
...
} |