fork download
  1. Map<String, Integer> studentScores = new Map<String, Integer>{
  2. 'Alice' => 85,
  3. 'Bob' => 92,
  4. 'Charlie' => 78
  5. };
  6.  
  7. // Access values using keys
  8. System.debug(studentScores.get('Alice')); // Output: 85
  9. System.debug(studentScores.get('Bob')); // Output: 92
  10.  
  11. // Iterate over the map
  12. for (String student : studentScores.keySet()) {
  13. System.debug(student + ' scored ' + studentScores.get(student));
  14. }
  15.  
  16. // Output:
  17. // Alice scored 85
  18. // Bob scored 92
  19. // Charlie scored 78
Success #stdin #stdout #stderr 0.01s 8956KB
stdin
Standard input is empty
stdout
Object: nil error: did not understand #<
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #< (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:1)
stderr
./prog:8: expected expression