Since we have the basic functionality of a hash map, let’s create a test instance of one for us to make sure everything works as expected.



Outside the HashMap class (completely unindented below the class definition) create a new hash map called hash_map. Give it an array size of 20.


We want to use this hash map to store geologic information — types of rocks.

In hash_map save the value "metamorphic" for the key "gneiss".


Now retrieve the value of hash_map for the key gneiss. Print it out, does your HashMap work as expected?

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?