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
Were can i watch unexpected free season 3
Vesna [10]

Answer:

Netflix

Explanation:

3 0
3 years ago
Drag the system component on the left to the device or program that fits with the system component.
Strike441 [17]

Answer:

A. Back up software - Utility software

B. Printer - Device drivers

C. Camera - Firmware

D. Television - Firmware

E. Games console - Firmware

F. Antivirus software - Utility software

G. Disk Cleaner - Utility software

H. Video Card - Device drivers

Explanation:

Computer system components are the physical or hardware and software parts of the device. It is a combination of system software like utility software, device drivers and firmware, application software, and the hardware components and kernel.

4 0
3 years ago
Aristotle came up with many reasons why statesmen should know all the different types of
leonid [27]
So states men could be reelected
7 0
4 years ago
A ________ is a temporary symbol or variable that you can replace subsequently with an element of your choice
dezoksy [38]
I believe the answer you are looking for is what's called an assignment statement. In computer programming, an assignment statement sets and/or resets the value stored in the storage location(s) denoted by a variable name; in other words, it copies a value into the variable. Also, in most imperative programming languages, the assignment statement or expression is a fundamental construct.
5 0
4 years ago
In which type of essay would you expect to find the following passage? one of the biggest difficulties this town faces is heavy
luda_lava [24]
Problem and solution 

6 0
3 years ago
Read 2 more answers
Other questions:
  • Complete the sentences to describe file options categories
    14·2 answers
  • What is an enterprise system
    14·2 answers
  • CRM systems provide an organization with an important element: all employees of the company who directly or indirectly serve a c
    9·1 answer
  • Money from a Coverdell Education Savings Account can be used for:
    11·1 answer
  • Two ways in which the media does not reflect the society you live in.
    9·1 answer
  • It is believed that Taiwan is the original home of these early Oceania explorers. Maori Lapita Polynesians Aborigines
    13·2 answers
  • Lập trình web truy vấn csdl và hienr thị ra màn hình danh sách các bản ghi
    15·1 answer
  • Write a program that prints the following 45 pairs of numbers:
    8·1 answer
  • Place the steps in order for manually creating a New Contact Group
    10·2 answers
  • How do I change my username/display name
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!