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
viktelen [127]
3 years ago
6

Write a method manyStrings that takes an ArrayList of Strings and an integer n as parameters and that replaces every String in t

he original list with n of that String. For example, suppose that an ArrayList called "list" contains the following values:("squid", "octopus")And you make the following call:manyStrings(list, 2);Then list should store the following values after the call:("squid", "squid", "octopus", "octopus")As another example, suppose that list contains the following:("a", "a", "b", "c")and you make the following call:manyStrings(list, 3);Then list should store the following values after the call:("a", "a", "a", "a", "a", "a", "b", "b", "b", "c", "c", "c")You may assume that the ArrayList you are passed contains only Strings and that the integer n is greater than 0.
Computers and Technology
1 answer:
raketka [301]3 years ago
3 0

Answer:

public static ArrayList manyStrings(ArrayList<String> list, int n){

    ArrayList<String> newList = new ArrayList<String>();

    for (int i=0; i<list.size(); i++) {

        for (int j=0; j<n; j++) {

            newList.add(list.get(i));

        }

    }

    return newList;

}

Explanation:

Create a method called manyStrings that takes two parameters, list and n

Create a new ArrayList that will hold new values

Create a nested for loop. The outer loop iterates through the list. The inner loop adds the elements, n of this element, to the newList.

When the loops are done, return the newList

You might be interested in
A student dissolves some solid sodium hydroxide in a beaker of water.
STALIN [3.7K]
C water is the soulute
7 0
3 years ago
Read 2 more answers
I want to discard my old computer and want to securely erase the data from my hard drive what is the process called.
laiz [17]
I believe the process is called High Level Format.
8 0
4 years ago
Read 2 more answers
5) Match the following.
statuscvo [17]
1 .hub
2.server
3.Network Interface
4.Workstation


I’m sorry if I’m wrong :(

I hope it helps
8 0
3 years ago
Which of the following best explains the different between Cut and Copy? a. When you copy text you are permanently deleting it,
Vilka [71]
B. When you copy text it remains in its original location and places it on the clipboard. Cutting text removes it from its original location and places it on the clipboard

5 0
3 years ago
Read 2 more answers
A notebook computer is set up to take maximum advantage of power saving features including shutting down the display and the har
astra-53 [7]

Answer:

The reason is that the windowing system consumes significantly more memory and virtual memory than the text mode.

Explanation:

The reason behind the occurrence of this is that the windowing system consumes significantly more memory and virtual memory than the text mode. As a result, this reduces the likelihood of the hard disk becoming inactive for long enough for it to be powered down by itself with no direct human control, i.e. automatically.

6 0
3 years ago
Other questions:
  • The security administrator for PLABS.com recommends using a host-based firewall for all servers and workstations. What can a hos
    6·1 answer
  • Create a class called Toddler that inherits from a class called Parent. (Note that Parent has already been defined elsewhere, so
    8·2 answers
  • On a piano, each key has a frequency, and each subsequent key (black or white) is a known amount higher. Ex: The A key above mid
    14·1 answer
  • A technician is troubleshooting a printer connected to a computer via USB. The printer will print using the controls at the prin
    9·1 answer
  • How many bits are reserved for the Transmission Control Protocol (TCP) flags?
    11·1 answer
  • A company has a number of employees. The attributes of EMPLOYEE include Employee ID (identifier), Name, Address, and Birthdate.
    11·1 answer
  • How do I log into PGCPS?
    14·1 answer
  • Complete the sentence.
    8·2 answers
  • How did transistors revolutionize the world of computers?
    15·1 answer
  • 30 POINTS FOR THE CORRECT ANSWERS
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!