Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a method to retrieve Employee objects from a HashMap. The method takes in

ID: 3931825 • Letter: W

Question

Write a method to retrieve Employee objects from a HashMap. The method takes in a HashMap that holds take in a HashMap that holds Employee objects hashed by their employee ID. The method also takes in a list of Employee IDs. Some IDs might be in the HashMap, others might not. Create a list of all Employee objects that match the IDs from the list and are eligible for a bonus. The Employee class is contained in the downloads for this homework. The method header is: public static ArrayList getEmployeeBonusList(HashMap employeeMap, ArrayList employeeIDs)

Explanation / Answer

Answer:

   public static ArrayList getEmployeeBonusList(HashMap employeeMap, ArrayList employeeIDs){
       ArrayList employeeList = new ArrayList();
       for(int i=0; i<employeeIDs.size(); i++){
           if(employeeMap.get(employeeIDs.get(i)) != null){
               employeeList.add(employeeMap.get(employeeIDs.get(i)));
           }
       }
       return employeeList;
   }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote