fork download
  1. public class DepartmentEmployees {
  2.  
  3. public static void main() {
  4. // Create a map with department names as keys and lists of employee names as values
  5. Map<String, List<String>> departmentEmployeesMap = new Map<String, List<String>>();
  6.  
  7. // Add sample data to the map
  8. departmentEmployeesMap.put('Sales', new List<String>{'Alice', 'Bob', 'Charlie'});
  9. departmentEmployeesMap.put('Engineering', new List<String>{'Dave', 'Eve', 'Frank'});
  10. departmentEmployeesMap.put('Marketing', new List<String>{'Grace', 'Heidi', 'Ivan'});
  11.  
  12. // Print the map
  13. for (String department : departmentEmployeesMap.keySet()) {
  14. System.debug('Department: ' + department);
  15. System.debug('Employees: ' + departmentEmployeesMap.get(department));
  16. }
  17. }
  18. }
  19.  
Success #stdin #stdout #stderr 0.01s 9048KB
stdin
Standard input is empty
stdout
Object: UndefinedObject error: did not understand #DepartmentEmployees
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject class(Object)>>doesNotUnderstand: #DepartmentEmployees (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:1)
stderr
./prog:3: parse error, expected '}'