1. Learn
  2. /
  3. Courses
  4. /
  5. Data Types and Exceptions in Java

Connected

Exercise

Working with HashMap

Create a HashMap to hold a company's directory of employees. That is a directory of Integer ids that point to String names in a lookup table. You will add a new employee as well as remove an employee from the directory.

Instructions

100 XP
  • Import HashMap for use in the application.
  • Set the variable directory to a new instance of HashMap of Integers and Strings.
  • Add a new employee (name of "Marcia" and id of 31) to the directory map.
  • Remove "Davy" with id of 45 from the directory map.