COP 3530 Section U03 Fall 2017 The HashSet Example =================== import java.util.*; /** * * @author pelina */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // form a set Set s = new HashSet(); System.out.println("We add joe, alex, bill," + "mark, mary, susan, mary."); s.add("joe"); s.add("alex"); s.add("bill"); s.add("mark"); s.add("mary"); s.add("susan"); s.add("mary"); // no effect // print the collection System.out.println("The set is:"); for (String val: s) System.out.println(val); // delete bob and mark s.remove("bob"); // no effect s.remove("mark"); // print the collection System.out.println("The set after removing bob and mark."); for (String val: s) System.out.println(val); // test contains boolean test1 = s.contains("mark"); boolean test2 = s.contains("bill"); System.out.println("mark is in the set is " + test1); System.out.println("bill is in the set is " + test2); } } /* the ouput We add joe, alex, bill,mark, mary, susan, mary. The set is: joe bill susan mark alex mary The set after removing bob and mark. joe bill susan alex mary mark is in the set is false bill is in the set is true */