With Java 8 you can use stream
and collect
to copy the items:
Set- newSet = oldSet.stream().collect(Collectors.toSet());
Or you can collect to an ImmutableSet
(if you know that the set should not change):
Set- newSet = oldSet.stream().collect(ImmutableSet.toImmutableSet());