Map<String, Integer> studentScores = new Map<String, Integer>{
'Alice' => 85,
'Bob' => 92,
'Charlie' => 78
};
// Access values using keys
System.debug(studentScores.get('Alice')); // Output: 85
System.debug(studentScores.get('Bob')); // Output: 92
// Iterate over the map
for (String student : studentScores.keySet()) {
System.debug(student + ' scored ' + studentScores.get(student));
}
// Output:
// Alice scored 85
// Bob scored 92
// Charlie scored 78
TWFwPFN0cmluZywgSW50ZWdlcj4gc3R1ZGVudFNjb3JlcyA9IG5ldyBNYXA8U3RyaW5nLCBJbnRlZ2VyPnsKICAgICdBbGljZScgPT4gODUsCiAgICAnQm9iJyA9PiA5MiwKICAgICdDaGFybGllJyA9PiA3OAp9OwoKLy8gQWNjZXNzIHZhbHVlcyB1c2luZyBrZXlzClN5c3RlbS5kZWJ1ZyhzdHVkZW50U2NvcmVzLmdldCgnQWxpY2UnKSk7ICAvLyBPdXRwdXQ6IDg1ClN5c3RlbS5kZWJ1ZyhzdHVkZW50U2NvcmVzLmdldCgnQm9iJykpOyAgICAvLyBPdXRwdXQ6IDkyCgovLyBJdGVyYXRlIG92ZXIgdGhlIG1hcApmb3IgKFN0cmluZyBzdHVkZW50IDogc3R1ZGVudFNjb3Jlcy5rZXlTZXQoKSkgewogICAgU3lzdGVtLmRlYnVnKHN0dWRlbnQgKyAnIHNjb3JlZCAnICsgc3R1ZGVudFNjb3Jlcy5nZXQoc3R1ZGVudCkpOwp9CgovLyBPdXRwdXQ6Ci8vIEFsaWNlIHNjb3JlZCA4NQovLyBCb2Igc2NvcmVkIDkyCi8vIENoYXJsaWUgc2NvcmVkIDc4