Here you can find the source of copySet(Set
public static <E> void copySet(Set<E> src, Set<E> dest)
//package com.java2s; //License from project: Apache License import java.util.Iterator; import java.util.Set; public class Main { public static <E> void copySet(Set<E> src, Set<E> dest) { for (Iterator<E> it = src.iterator(); it.hasNext();) { dest.add(it.next());// w ww .j a v a2s. co m } } }