Question: Revise the bag class so that it is a bag of strings rather than integers. For the methods that add strings to the bag, you
Revise the bag class so that it is a bag of strings rather than integers. For the methods that add strings to the bag, you should alwaysaulwseaythse string’s clone method to make a copy of each string and put the copy into the clone rather than the original. Also, when you are comparing two strings for equality, make sure you use the string equals method rather than the == operator. Modify the bag test applet from Appendix I to test your new string bag.
Step by Step Solution
3.41 Rating (167 Votes )
There are 3 Steps involved in it
public class StringBag private String data private int manyItems public StringBagint initialCapacity if initialCapacity 0 throw new IllegalArgumentExc... View full answer
Get step-by-step solutions from verified subject matter experts
