why no replace() method defined on the Set interface ?

Posted by elec on Stack Overflow See other posts from Stack Overflow or by elec
Published on 2010-04-14T10:41:25Z Indexed on 2010/04/14 10:53 UTC
Read the original article Hit count: 174

Filed under:

Currently I have to write the following to update an element contained in a Set:

Set mySet= ...
if (mySet.contains(element)){
    mySet.remove(element);
    myset.add(element);
 }

That doesnt look nice. Is there an alternative ?

© Stack Overflow or respective owner

Related posts about java