Relative Content

Tag Archive for arraylistduplicates

Missed an element while removing all occurrence in an ArrayList in Java

This is a simple code but sometimes the results is not as expected.
I have an ArrayList containing Integers and some elements are duplicates. I wanted to remove all occurrence of the duplicate ones for a certain_val. Most time it worked good and removed all. But sometimes it may miss one and did not remove all the occurrence. The code is as following: