<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import java.util.*;

public class StringSetApplication {
    
    private static final int maxLen = 6;

    /* Given an object from a class that implements the Collection interface
       remove all the objects that are longer than maxLen. */
    public static void removeLongStrings(Collection coll) {
	Iterator it = coll.iterator();
	while (it.hasNext()) {
	    String str = (String)it.next();
	    if (str.length() &gt; maxLen)
		it.remove();
	}
    }
    
    public static void main (String[] args) {
	
	StringSet aSet = new StringSet(12);
	StringSet bSet = null;
       
	aSet.add("March");
	aSet.add("June");
	aSet.add("September");
	aSet.add("December");

	try {
	    bSet = (StringSet)aSet.clone();
	} catch (CloneNotSupportedException e) {
	    System.out.println("Clone not supported exception caught.");
	    System.exit(0);
	}
	
	System.out.println(aSet);
	System.out.println(bSet);
	removeLongStrings(aSet);
	System.out.println(aSet);
	System.out.println(bSet);
    }
}
</pre></body></html>