Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help The assignment is the following Write a method called doubleList that takes an ArrayList of strings as a parameter and replaces every string

Please help

The assignment is the following

Write a method called doubleList that takes an ArrayList of strings as a parameter and replaces every string with two of that same string. 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. Print content of ArrayList before and after the method call.

What I have so far:

import java.util.ArrayList;

public class DoubleList { ArrayListarrList=new ArrayList(); arrList.add("how"); arrList.add("are"); arrList.add("you"); void DoubleList(arrList) { System.out.println(arrList); }

ScreenShot:image text in transcribed

Q 61-1-* * DoubleList.java X 1 import java.util.ArrayList; E Be Outline x 619 DoubleList arrList : ArrayList DoubleList(): void 3 public class Doublelist { ArrayListarrlist=new ArrayList(); 5 arrList.add("how"); 6 arrList.add("are"); 7 arrList.add("you"); X 90 void Doublelist(arrlist) { 10 System.out.println(arrList); 11 } 12 13

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions