Write a method to create a HashMap from a list of Employee o

Write a method to create a HashMap from a list of Employee objects.

The method takes in a list of Employee objects.

The method returns a HashMap that contains those employees hashed by their employee ID.

The Employee class is contained in the downloads for this homework.

The method header is:

public static HashMap<String, Employee> getEmployeeHash(ArrayList<Employee> employeeList)

Solution

   public static HashMap<String, Employee> getEmployeeHash(ArrayList<Employee> employeeList){
       HashMap<String, Employee> map = new HashMap<String, Employee>();
       for(Employee emp: employeeList){
           map.put(emp.getEmployeeID(), emp);
       }
       return map;
   }

Write a method to create a HashMap from a list of Employee objects. The method takes in a list of Employee objects. The method returns a HashMap that contains t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site