abhinas raj wrote:i am trying to remove the duplicate values from HashMap by the following code but it is thwoing following exception
java.util.ConcurrentModificationException how to remove duplicate values ?
Basically, you are not allowed to directly modify the collection while you are iterating through the collection.
You can only modify the collection via the iterator, while iterating through the collection. And of course, you don't have access to the iterator because you are using the for-each loop. You need to switch it to the regular for loop, and modify the collection via the iterator only.