Question PRG-JAVA-0019
HardWhat happens when you modify an ArrayList while iterating over it with a for-each loop?
- A.
Nothing special happens
- B.
The list is copied automatically
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Java question
What happens when you modify an ArrayList while iterating over it with a for-each loop?
Nothing special happens
The list is copied automatically
Sign up free to see the answer and a step-by-step explanation.
A ConcurrentModificationException is usually thrown
The loop skips the new element silently