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
Heres a survey
vodka [1.7K]

food.

I'm a child of God snatching lost souls out of Hell

bake

I go to church

some is to much information to give thx and have a blessed day

4 0
3 years ago
Read 2 more answers
Design and implement an application that reads an integer value representing a year from the user. The purpose of the program is
olga55 [171]

Answer :

Written in java

import java.util.Scanner;

public class Main{

   public static void main(String[] args) {

       int year;

       Scanner scanner = new Scanner(System.in);

       System.out.print("Please enter a year\n\n");

       year = scanner.nextInt();

       while (year < 1582) {

           System.out.print("\nPlease enter a different year above 1582\n");

           year = scanner.nextInt();

       }

       if (year % 4 == 0) {

           if(year % 100 ==0 && year % 400 != 0){

                   System.out.println(year + " is not a leap year\n\n");

           }else {

               System.out.println(year + " is a leap year\n");

           }

       } else {

           System.out.println(year + " is not a leap year\n\n");

       }

   }

}

4 0
3 years ago
You are writing an email to a potentional employer about a job opportunity. What can you do to make sure the email reflects your
Lina20 [59]
You want to use proper etiquette and be polite, do not call them by their first name and always refer to them as Mr., or Mrs. Use an extended vocabulary and do not talk about yourself.  If you have proper grammar, depending on the job, that can be seen as intelligence. And always use an appropriate closing that is respectful. Such as, Sincerely, John Doe.
4 0
4 years ago
Read 2 more answers
How can I find all the answers for the NWEA MAP Math, English, Reading, and Science tests? Please help!!!!! I found some answers
Gala2k [10]

Answer:

if its a test try to just do it on your own ,you got nothing to lose from a test, its just to understand what you know on the concepts, but if you would still like answers just search around the net or here and you can always post the questions to ask people for help someone would eventually answer your questions but then beware of bots that post links as answer!

Explanation:

6 0
3 years ago
Explain what the loop does and what the result of executing it will be.
Studentka2010 [4]

Answer:

The loop increments the value of new while the loop condition is true

The end value of new is 3

Explanation:

Given

The above code segment

Required

What the loop does and the result

We have:

new = 0 --- initialize new to 0

i = 3; i \le 5; i++ --- The loop condition;

i.e. the loop will be repeated 3 times (when i = 3, 4 and 5)

new = new + 1 --- For each increment of i, new is incremented by 1

So, the value of new is:

<em>i = 3: new = 0 + 1 = 1</em>

<em>i = 4: new = 1 + 1 = 2</em>

<em>i = 5: new = 2 + 1 = 3</em>

5 0
3 years ago
Other questions:
  • Fibre channel switched networks rely on the concept of a ___________________which is a fundamental concept in how the network wo
    10·1 answer
  • The design activity key question, "how will this system interact with other systems..." is part of which design activity?​
    7·1 answer
  • Emilio is reviewing the data he collected from historical records about immigration in the united states. He decides to create a
    5·1 answer
  • The presentation ____ determines the formatting characteristics of fonts and colors.
    8·1 answer
  • 1. Hypothesis: It is easier to establish an ethical work environment in a non-profit organization than in a for-profit organizat
    9·1 answer
  • Write a program code to accept the names of 3 users and generate a user name as shown in the example. Accept the name of 3 user
    9·1 answer
  • ___________allows you to see what the final web page will look like.​
    10·1 answer
  • A flowchart meeting is a process where members of the team analyze the design piece-by-piece to make sure it meets requirements
    15·1 answer
  • X = 9 % 2<br><br> if (x == 1):<br>   print ("ONE")<br> else:<br>   print ("TWO")
    5·2 answers
  • dion training just installed a new webserver within a screened subnet. you have been asked to open up the port for secure web br
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!