Discussion
Which of these statements about what Map.Entry.setValue does is correct?
Answer: D
Correct answer: It writes the new value through to the map the entry came from.
A Map.Entry obtained from entrySet() is a view onto the map, so setValue updates the mapping itself - which is the supported way of modifying values while iterating a map. The entry is valid only for the duration of the iteration, and its behaviour afterwards is undefined; an unmodifiable map is the case that throws UnsupportedOperationException.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development