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]
4 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]4 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
Which term is used to identify the connection of computers that are physically close to one another?
marta [7]

Answer: Local Area Network (LAN)

Explanation:

A Local Area Network (LAN) is a computer network that interconnects computers within a limited physical area such as a residence, school, laboratory, university campus or office building.

An example of  LAN network is "Phone, Computer and TV connected to a single network (such as a Home Network) via Cables, Wifi, Bluetooth or Hotspot". When the devices are interconnected or connected to a LAN, it becomes accessible between each other.

A simplest example of a LAN Device is a <em>Home Router.</em>

6 0
3 years ago
Read 2 more answers
The _________ operator returns the distance in bytes, of a label from the beginning of its enclosing segment, added to the segme
DanielleElmas [232]

Answer:

C. Offset.

Explanation:

An offset operator can be defined as an integer that typically illustrates or represents the distance in bytes, ranging from the beginning of an object to the given point (segment) of the same object within the same data structure or array. Also, the distance in an offset operator is only valid when all the elements present in the object are having the same size, which is mainly measured in bytes.

Hence, the offset operator returns the distance in bytes, of a label from the beginning of its enclosing segment, added to the segment register.

For instance, assuming the object Z is an array of characters or data structure containing the following elements "efghij" the fifth element containing the character "i" is said to have an offset of four (4) from the beginning (start) of Z.

8 0
3 years ago
Oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
mihalych1998 [28]

Answer:

ooooooooo[soooooooo ioooo egg vn

8 0
3 years ago
Why is a positive attitude towards work important
bezimeni [28]

Answer:

it lets you get more work done

Explanation:

when you have a positive work attitude you want to do more stuff, and when it's bad you won't want to do anything

3 0
3 years ago
Denary is measured in Base 10 Binary is measured in Base________
anastassius [24]

Answer:

hey! the answer to your question is -

binary is measured in base 2

3 0
3 years ago
Other questions:
  • What are the three main purposes of an operating system? Explain how the old mainframe computers were different from the compute
    12·1 answer
  • When law enforcement becomes involved, the need may arise to freeze systems as part of the evidence. There is also the likelihoo
    5·1 answer
  • When elements are placed on the page so that text and graphic elements are evenly distributed you have:
    9·1 answer
  • On hearing my name, you may think that I am iterative, but I play a vital role in networking by boosting the signal strength to
    13·1 answer
  • The maximum number of colors that should be used on a slide is _____. 2 4 6 8
    5·1 answer
  • The MAA is responsible on a daily basis to protect office computers and patient records and personal information from hackers. R
    12·1 answer
  • What does resolution mean on a computer monitor?
    9·2 answers
  • What is the first step that you have to perform before you can add a windows package to a wim file?
    9·1 answer
  • Guess The Song: <br> What Popping Brand New Whip Just Hopped In, I Got options
    15·1 answer
  • How can you stay safe on the Internet? Check all that apply.
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!