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]
4 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]4 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
The IT department at Piggy Parts BBQ has recently learned of phishing attempts that rely on social engineering to break into its
Katen [24]

Answer:

all personnel

Explanation:

According to my research on information technology and cyber security, I can say that based on the information provided within the question this information should be communicated to all personnel. This should be done as a safety precaution, by making all personnel aware of they would know to speak up if they see anything suspicious otherwise they might think an attack is just part of something that the organization is implementing.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

6 0
3 years ago
Choose
Arisa [49]

Answer:

1. option A simultaneously

2.option A undo

6 0
3 years ago
1 _ A Unit of information containing the object's position: rotation, and scale values is called:
Damm [24]

Answer:

an inform

Explanation:

A information is an inform

4 0
3 years ago
Jerry keeps a spreadsheet of all the tools he owns. He wants to figure out
Evgen [1.6K]

Answer:

It's B and C

Explanation:

As because first you have to write the formula in any cell like to write the total if u want to to write in negative than it's B and If u want in positive than it's C. And see the above pictures to get it perfectly

7 0
3 years ago
Read 2 more answers
What are the external parts of a computer system? Which are input and output?
____ [38]
Input for example is a mouse, keyboard, microphone while an output is a monitor, headset/speakers.
an input sends data into the computer while an output sends it out again,
hope this helps
4 0
3 years ago
Read 2 more answers
Other questions:
  • What do you think about the argument that word processing reduces the quality of writing?
    11·1 answer
  • Write a complete function called lowestPosition() which takes as array (of double) and the number of elements used in the array
    9·1 answer
  • A bank has reworked its mortgage application process so that several steps are handled by computer software, and some steps are
    11·1 answer
  • after installing a secondary hard drive what needs to be done to the hard drive and what do these two task do?
    12·1 answer
  • 1. Write a program to input four numbers and store them in variables.
    6·1 answer
  • A restaurant recorded the ages of customers on two separate days. You are going to write a program to find the minimum age of a
    5·2 answers
  • When measuring processor speed,a megahertz is much faster than a gigahertz.true or fals
    12·1 answer
  • ……………………is one of the most popular cloud storage facilities.​
    11·1 answer
  • A large, closet-sized computer capable of simultaneously processing data for hundreds or thousands of users is most likely a ___
    14·1 answer
  • The scope of a temporary table is limited to what?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!