-
Map Interface in Java
over 9 years ago
- clear() : It clears all pairs from the given map.
- boolean containsKey(Object thisKey) : It will return true if the map contains thisKey as a key.
- boolean containsValue(Object thisValue) : It will return true if the map contains thisValue as a value.
- Object put(Object key, Object value): It will add this pairs to the given Map and overwrite the value if
key already exist.
- int size() : Returns the number of pairs in the given Map.
Example:
- Map mapExample = new HashMap();
- mapExample.put(k1,Java1);
- mapExample.put(k2,Java2);
- mapExample.put(k3,Java3);
- mapExample.put(k4,Java4);
- System.out.println(Map : : +mapExample);
0 Comment(s)