This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The mapping is removed. This means both key and value. If you only want to remove the value, use "put(key, null)".
The second one can be obtained using addAll and removeAll:
With most collections you can combine the first two lines:
That second answer is in the API of Set#removeAll though:
Removes from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.
[ October 02, 2008: Message edited by: Rob Prime ]