Created: 2023-09-03 20:46
Status: #concept
Subject: Programming
Tags: Java java.util java.util.HashMap Java Interface
java.util.Map
It is a mapping of keys to values.
The Map interface provides three collection views, which allow a map's contents to be viewed as a .keySet()
, collection of .values()
, or set of key-value mappings which we can .put(key, value)
or .get(key)
.
All Known Implementing Classes:
Map<String, String> maps = new HashMap<>();
maps.put("ganbatte", "good luck");
maps.put("hai", "yes");
for (String key : maps.keySet()) {
System.out.println(key + ": " + maps.get(key));
}
// ganbatte: good luck
// hai: yes