HashMap

Java HashMap
In the chapter, you learned that Arrays store items as an ordered collection, and you have to access them with an index number ( int type). A HashMap however, store items in " key/ value" pairs, and you can access them by an index of another type (e.g. a String).
https://www.w3schools.com/java/java_hashmap.asp

Include

import java.util.HashMap;

Init

HashMap<type, type> mapName = new HashMap<type, type>();

Functions

// adds value to map
mapName.put(key, val);

// returns the size
mapName.size();

// replaces the value in a key
mapName.replace(key, newVal);


// returns true if value is in the map
mapName.containsValue(val);

// returns true if key is in the map
mapName.containsKey(key);