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

1 Expert Approved Answer
Step: 1 Unlock

public class StringBag private String data private int manyItems public StringBagint initialCapacity if initialCapacity 0 throw new IllegalArgumentExc... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Data Structures and Other Objects Using Java Questions!