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
Time shifting occurs when
Aleksandr-060686 [28]
Answer: C

Time shifting is when you move from one period in time to another.
4 0
3 years ago
Read 2 more answers
The part of the computer that provides access to the internet is the
Arlecino [84]
<span>The part of the computer that provides access to the internet is the "modem".
</span>

A modem refers to a hardware device that enables a PC to send and get information over a phone line or a link or satellite association. On account of transmission over a simple phone line, which was at one time the most prevalent approach to get to the internet, the modem changes over information amongst simple and computerized designs progressively for two-way network communication.
4 0
2 years ago
Read 2 more answers
Buying a new computer for which of these reasons is most likely a sound
Svetllana [295]

Answer:

b. you need it to do your homework

Explanation:

3 0
2 years ago
Consider the following program. Assume all variables are declared and the program compiles.
Alexus [3.1K]
Hard question thx for the points give me brainlest points plz
8 0
2 years ago
What is the correct term for a set of established guidelines for actions (which may be designated by individuals, teams, functio
serg [7]

Answer: Protocol

Explanation: Protocol is the standard that is used in the communication and electronic devices for the communication. Through the mean of the these guidelines the communication is done by the sending and receiving of the data.

This works for the both wired networking and wireless communication which functions under the certain conditions.Examples-TCP(Transmission control protocol), FTP(File transfer protocol) etc.

5 0
3 years ago
Other questions:
  • HELP PLEASE
    7·2 answers
  • Do routers have ip addresses? if so, how many?
    10·1 answer
  • What is the best reason to delete Internet browsing history on a regular basis? to solve a computer hardware problem to protect
    13·2 answers
  • 3. Assume a disk drive from the late 1990s is configured as follows. The total storage is approximately 675MB divided among 15 s
    11·1 answer
  • The use of electronic media, information, and communication technologies to deliver instruction where students are not required
    8·1 answer
  • 9
    10·1 answer
  • The name of a person their address and their contact information like phone number and email address or consider the minimum inf
    9·1 answer
  • Complete each sentence using the drop-down menu. Information on local driving laws can be found on a website. A class textbook c
    9·2 answers
  • Algorithm and flowchart:- find the product of two number (a and b)​
    11·1 answer
  • True/False: On the piano, middle C is located to the left of the 2 black keys in the middle.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!