This lets us search for the items in each collection. We can make it a bit harder to search for objects that are not in the collection, but we can index items that are in the collection.
Using an array index can be a bit trickier, but with a little help from your knowledge of Java, you can do it. We have a HashMap of objects, and we want to find the object that matches this key. So we can think of this as an array. We can index the array by this key (the key is the same as the hash-map’s key), and then find the object by the value.
In the past I’ve written this as a nested for loop, but since you can use an array as a hash-map we can simplify it to a single pass. The key is a number, so we can make the index look like a number. The value is an object, and we want to find the object that matches this key. So we just use the same index/hash-map trick as before.