Question: This code attempts to remove all of the odd numbers from the ArrayList. But, if you compile and run it , you will notice that
This code attempts to remove all of the odd numbers from the ArrayList. But, if you compile and run it you will notice that JAVA generates ajava.util.ConcurrentModificationException. This is because JAVA does not allow you to modify a collection such as an ArrayList while you are looping through it So we cannot simply go through and remove the odd numbers in this way.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
