import java.util.*; // A brief review of how to use, iterate through, and // remove from sets/maps. public class SetMapReview { public static void main(String[] args) { // Create a set of Strings, add some strings Set s = new HashSet(); s.add("Melissa"); s.add("Adam"); s.add("Martin"); // Print out each string on its own line for (String name : s) { System.out.println(name); } // Create a map of the strings to their length. Map lengths = new HashMap(); for (String name : s) { lengths.put(name, name.length()); } // Remove any strings from the map of even length Iterator iter = lengths.keySet().iterator(); while (iter.hasNext()) { String name = iter.next(); if (name.length() % 2 == 0) { iter.remove(); } } } }