Passing a set to create a new set

java, set

Solution

Set newSet = new HashSet(oldSet);

This makes a copy of the old set; any changes made to old set after this do not affect the new set.

Problem

While passing a set to create a new set in java,any modifications made to the new set also modifies the original set.How do I pass the set so that any changes made to the new one doesn't affect the original one?

Original source