1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
svetlana [45]
3 years ago
12

Reimplement StringSet with the exception that it should now extend ArrayList instead of encapsulating a String[]. You can easily

abolish the 10 String limit for this new StringSet. You can also remove the int instance variable, as your class will no longer need it. Your existing StringSetTester should work with the new StringSet without being changed. Hint: What type of elements did the original StringSet store? What type of elements will be inserted into our ArrayList superclass? How can we tell Java that our ArrayList will be storing that type of element?
Computers and Technology
1 answer:
kolbaska11 [484]3 years ago
4 0

Answer:

Here is the program for the given question

Explanation:

class StringSet

{

ArrayList<String> arraylist; //a reference variable of ArrayList of generic type String

//A no argument constructor.

public StringSet()

{

arraylist=new ArrayList<String>(); //instantiating the ArrayList object

}

//A mutator that adds a String newStr to the StringSet object.

void add(String newStr)

{

arraylist.add(newStr); // add(String) method to add string to the arraylist

}

//An accessor that returns the number of String objects that have been added to this StringSet object.

int size()

{

return arraylist.size(); // size() method which gives the number of elements in the list

}

//An accessor that returns the total number of characters in all of the Strings that have been added to this StringSet object.

int numChars()

{

int sum = 0;

for(String str:arraylist) //for-each loop; can be read as for each string in arraylist

{

sum+=str.length();

}

 

return sum;

}

//An accessor that returns the number of Strings in the StringSet object that have exactly len characters.

int countStrings(int len)

{

int count = 0;

for(String str:arraylist)

{

if(str.length() == len)

count++;

}

return count;

}

}

You might be interested in
Microsoft <br> Excel Module 6
Sonbull [250]

Answer:

what Is your question?

6 0
3 years ago
In HTML, an opening tag and its closing tag must appear on the same line. True Or False​
DaniilM [7]

Answer:

the answer is true, you cannot break the element apart EVERR!!!!!

3 0
3 years ago
The mode is least appropriate for:___________
bazaltina [42]

Answer:

Your question seems incomplete

Explanation:

7 0
3 years ago
A popular Voice over Internet Protocol (VoIP) service is ________.
Aloiza [94]
The answer would be Skype
8 0
3 years ago
How many years does it take in total to complete Bachelor’s, Master’s, and Phd in CS?
muminat

Answer:

3 years of study - Bachelor's degree

2 years of research - Master's degree

3 years of research to earn a PhD

So, On total it would take 8 years!

7 0
3 years ago
Other questions:
  • Sue conducted an experiment to determine which paper towel is the most absorbent among three different brands. She decides to pr
    15·1 answer
  • Which two statements about using leased lines for your wan infrastructure are true? (?
    14·1 answer
  • Which type of JPEG image records the most information in the digital file? Medium Low Fine Expert
    6·2 answers
  • The process of engineering design typically starts with what ?
    12·1 answer
  • True or false
    10·1 answer
  • I made Pico with a Ray Gun (Next is Dad/Tankman)<br><br> Opinons?
    11·2 answers
  • Using the Insert tab, you can convert text into a table and a table into text.
    15·1 answer
  • Camila wanted to increase the readability of her company newsletter. To do this, she added _____.
    7·2 answers
  • Write a program that asks the user for the name of a text file. The program should display the first 10 lines of the file on the
    6·1 answer
  • What makes a recipe for a meal an example of an algorithm?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!