Попробуйте:
public class MyReplicatingClass {
private static ArrayList<String> arrayList;
public static void main(String[] args) {
arrayList = new ArrayList<>();
arrayList.add("how");
arrayList.add("are");
arrayList.add("you");
System.out.println(arrayList);
doubleList(arrayList);
System.out.println(arrayList);
}
private static void doubleList(ArrayList<String> list) {
ArrayList<String> tmpList = new ArrayList<>();
for (String element : list) {
int numOfRepeats = 2; // can be changed to 3 -> [how, how, how, ...]
while (numOfRepeats > 0) {
tmpList.add(element);
numOfRepeats--;
}
}
arrayList = new ArrayList<>(tmpList);
}
}
Как указано выше, его можно настроить.Вот вывод для повторения 6:
[how, are, you]
[how, how, how, how, how, how, are, are, are, are, are, are, you, you, you, you, you, you]