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
Why do bats sleep upside down
seraphim [82]

Answer:

Bats cannot run so it would be almost impossible for them to take off from the ground. A major advantage to hanging upside down is that bats do not need to generate lift to begin flight. They just drop out of their bed, open their wings and off they go.

Explanation:

8 0
3 years ago
Read the paragraph.
aleksandrvk [35]

Answer:

I think sentence 3 bc it doesn't really make any sense Ik it's explaining it but it doesnt connect with the whole story as much I think it has to have more details

5 0
3 years ago
Read 2 more answers
Compared to using a command line, an advantage to using an operating system that employs a gui is ________.
artcher [175]

Compared to using a command line, an benefit to using an operating system that employs a GUI exists you do not have to memorize complicated commands.

<h3>What is operating system?</h3>

An operating system (OS) exists as the program that, after being initially loaded into the computer by a boot program, contains all of the other application programs on a computer. The application programs create use of the operating system by completing requests for services through a specified application program interface (API).

A GUI utilizes windows, icons, and menus to carry out commands, such as opening, deleting, and moving files. Although a GUI operating system is especially navigated using a mouse, a keyboard can also be utilized via keyboard shortcuts or arrow keys.

The GUI, a graphical user interface, exists as a form of user interface that permits users to interact with electronic devices via graphical icons and audio indicators such as primary notation, instead of text-based UIs, typed command labels, or text navigation.

Hence, Compared to using a command line, an benefit to using an operating system that employs a GUI exists you do not have to memorize complicated commands.

To learn more about operating system refer to:

brainly.com/question/22811693

#SPJ4

7 0
2 years ago
URGENT!!!
Alona [7]

False is your answer

5 0
3 years ago
Read 2 more answers
In the borders and shading dialog box where would you look to see if your border will have two sides
arlik [135]
On the preview box? I think. 
6 0
3 years ago
Read 2 more answers
Other questions:
  • Blender questions
    10·1 answer
  • when reading a recipe ingredients witch substance make the rice an unhealthy choice if it is present in a high amount
    13·1 answer
  • why do programs include keyboard shortcuts for certain actions? do you prefer the mouse or the keyboard/ why?
    7·1 answer
  • Develop a Matlab program that allows you to plot the entropy of a source with variable output probabilities. We wish to observe
    8·1 answer
  • You are evaluating the bounce rate of your overall website traffic and find that users with a social media referral source have
    9·1 answer
  • The process of combining rows and columns in a table is called _____.
    8·1 answer
  • Whats wrong with my code for .addEventListener
    11·1 answer
  • Can you help me, please
    10·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    11·2 answers
  • Help pweeze this is due today :(<br><br> I will give u brainliest just pweeze, I need this answer :(
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!