Open In App

Remove an Entry using value from HashMap while Iterating over it

Given a HashMap and a value in Java, the task is to remove an entry from this HashMap using the value, while iterating over it.

Examples:



Input: HashMap: {1=Geeks, 2=ForGeeks, 3=GeeksForGeeks}, value = “ForGeeks”
Output: {1=Geeks, 3=GeeksForGeeks}

Input: HashMap: {1=G, 2=e, 3=e, 4=k, 5=s}, value = k
Output: {1=G, 2=e, 3=e, 5=s}




Article Tags :