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
Naily [24]
3 years ago
10

Write a method doubleList that takes an ArrayList of Strings as a parameter and that replaces every string with two of that stri

ng. For example, if the list stores the values {"how", "are", "you?"} before the method is called, it should store the values {"how", "how", "are", "are", "you?", "you?"} after the method finishes executing.
Computers and Technology
1 answer:
erastovalidia [21]3 years ago
8 0

Answer:

// Method to double the content in a list

// Method receives an arraylist as parameter

public static void doubleList(ArrayList<String> stringlist) {

 // Create a new array list to hold the new content

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

 // Create a loop that cycle through the string list

 // For every cycle, get the current content of the list

 // and add it twice to the new list

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

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

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

 }

 // Copy the content of the new list back to the string list

 stringlist = newList;

 // Display the result

 System.out.println(stringlist);

}

Explanation:

Please go through the comments in the code for better understanding and readability.

Hope this helps!

You might be interested in
What do you remember about the difference between Canadian and US dollar (which one is greater)? Also, explain which online tool
Talja [164]
I’m not sure about USD but Canadian dollars are greater, one dollar CAD is equal to $0.79 US. So $10 CAD is equal to $7.90 US.
8 0
3 years ago
What is microsoft excel​
Andrei [34K]

Answer:

A spreadsheet program included in Microsoft Office suit of application. Spreadsheets present tables of value arranged in rows and columns that can be manipulated mathematically using both basic and advanced functions.

6 0
3 years ago
Read 2 more answers
An installation is:<br> please help asap
pogonyaev

Answer:  an installation is the act of putting something in, a device that stays in one place, a military base, or an art piece that often involves building and different types of materials.

Explanation:

Getting your new air conditioner put in is an example of an installation.

4 0
2 years ago
The New option is found in the ...............tab.​
morpeh [17]

in your notes books and in your vopy

3 0
3 years ago
Read 2 more answers
Why do we install doorbells in our house
Vinil7 [7]

Explanation:

It's placed near the door. When a visitor presses the button, the bell rings inside alerting you that someone is at the door.

6 0
2 years ago
Read 2 more answers
Other questions:
  • Laura is photographing her son’s baseball game. What ISO setting should she use?
    11·1 answer
  • When Clara accesses the programs and documents on her computer by way of icons, she is said to be employing
    15·1 answer
  • Please Do Solve it guys...
    6·1 answer
  • The Integers 10, 30, 20 are inserted in that order, into an AVL Tree. Which sequence of commands will make the correct method ca
    7·1 answer
  • Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. Promp
    10·1 answer
  • Recently, Walmart offered a wireless data contract based on bandwidth used, with a minimum monthly charge of $42 for up to 5 gig
    15·1 answer
  • A monopoly is a market that has few competing businesses. many sellers of the same item. many sellers of a variety of products.
    8·2 answers
  • Pleaseeeeeeeee I will give a brainliest
    7·1 answer
  • Does The ps5 digital have a disc drive even Though ps4 games are not compatible
    6·1 answer
  • before you start researching fleet management software, your first task is to clearly define the problem. this will help guide y
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!