What has ordering got to do with a Set? Sets do not support order, so a replace method would be pointless. In fact it would be difficult to implement for something like
HashSet. Using remove() and add() is the correct way to do it.
LinkedHashSet is a hybrid, a set combined with a sequence. But even that, which maintains original insertion order (ignoring re-insertion) does not support replace.
If you need a replace(E, E) method, override Set<E> to add a replace method and use an instance of that interface as a wrapper round a HashSet object.