Maps (aka Dictionaries)

  • Please read about Map and HashMap.
  • You do not need to do the programming exercises in the reading, but you may find it helpful to try them a little. It’s up to you.
  • Map data structure (also called a dictionary or associative array in other languages)
  • Keys vs values, key-value pairs
  • The Java Map interface has the get() method for looking up the value that corresponds to a given key. Why isn’t there a method that goes in the other direction, i.e. looking up the key that corresponds to a given value?
  • Is there a situation where containsKey(x) could return true, but then get(x) returns null? (Yes! What is it?)

What do you hope to learn about maps from the in-class activity?