import java.util.*; import java.awt.Color; import static java.awt.Color.*; public class d2 { public static void main(String[] args) { // populate first collection Collection hs1 = new HashSet(); hs1.add( red ); hs1.add( green ); hs1.add( blue ); hs1.add( magenta ); // populate second collection Collection hs2 = new HashSet(); hs2.add( red ); hs2.add( green ); hs2.add( yellow ); // intersect is the things that are in hs1 AND in hs2 Collection intersect = hs1; Collection hs3 = new HashSet (hs1); boolean ok = intersect.retainAll(hs2); System.out.println("intersect: " + intersect); System.out.println("hs1: " + hs1); System.out.println("hs3: " + hs3); } }