Question: Programming Problem 18.11 HashSet implementation with LabRat Turn the HashSet implementation of Chapter 16 into a generic class. Use an array list instead of an
Programming Problem 18.11 HashSet implementation with LabRat
Turn the HashSet implementation of Chapter 16 into a generic class. Use an array list instead of an array to store the buckets.
Use the following class as your main class:
import java.util.Iterator; /** This program demonstrates the hash set class. */ public class HashSetDemo { public static void main(String[] args) { HashSet names = new HashSet(101); // 101 is a prime names.add("Sue"); names.add("Harry"); names.add("Nina"); names.add("Susannah"); names.add("Larry"); names.add("Eve"); names.add("Sarah"); names.add("Adam"); names.add("Tony"); names.add("Katherine"); names.add("Juliet"); names.add("Romeo"); names.remove("Romeo"); names.remove("George"); Iterator iter = names.iterator(); while (iter.hasNext()) System.out.println(iter.next()); } } You need to supply the following class in your solution:
HashSet
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
