// Note the HashMap's "key" is a String and "value" is an Integer
HashMap<String,Integer> hm = new HashMap<String,Integer>();
// Putting key-value pairs in the HashMap
hm.put("Ava", 1);
hm.put("Cait", 35);
hm.put("Casey", 36);
// Using an enhanced loop to iterate over each entry
for (Map.Entry me : hm.entrySet()) {
print(me.getKey() + " is ");
println(me.getValue());
}
// We can also access values by their key
int val = hm.get("Casey");
println("Casey is " + val);
]]></code>
</example>
<description><![CDATA[
A <b>HashMap</b> stores a collection of objects, each referenced by a key. This is similar to an <b>Array</b>, only instead of accessing elements with a numeric index, a <b>String</b> is used. (If you are familiar with associative arrays from other languages, this is the same idea.) The above example covers basic use, but there's a more extensive example included with the Processing examples. In addition, for simple pairings of Strings and integers, Strings and floats, or Strings and Strings, you can now use the simpler IntDict, FloatDict, and StringDict classes.<br />
<br />
For a list of the numerous <b>HashMap</b> features, please read the <a href="https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html">Java reference description</a>.