Answer:
Explanation:
The following code is written in Java. It creates a function that takes in an ArrayList and an int parameter. Then it loops through the array and adds each element into a new array called newList but adds them the number of times that the numRepeats argument states. Output can be seen in the attached image below.
import java.util.ArrayList;
class Brainly{
public static void main(String[] args) {
ArrayList list = new ArrayList();
list.add('a');
list.add('b');
list.add('c');
ArrayList newList = repeatArrayList(list, 3);
System.out.println(newList);
}
public static ArrayList repeatArrayList(ArrayList list, int numRepeats) {
ArrayList newList = new ArrayList();
for (int x = 0; x < numRepeats; x++) {
for (int i = 0; i < list.size(); i++) {
newList.add(list.get(i));
}
}
return newList;
}
}