public class Solution {
public static void main(String[] args) throws Exception {
// Read strings from the console and declare an ArrayList here
ArrayList<String> strings = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 20; i++) {
strings.add(reader.readLine());
}
ArrayList<String> result = doubleValues(strings);
// Display result
for (int i = 0; i < result.size(); i++) {
System.out.println(result.get(i));
}
}
public static ArrayList<String> doubleValues(ArrayList<String> list) {
//write your code here
for (int i = 0; i < list.size(); i++) {
list.add(i,list.get(i));
i++;
}
return list;
}
}
package com.codegym.task.task07.task0717;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Duplicating words
*/
public class Solution {
public static void main(String[] args) throws Exception {
// Read strings from the console and declare an ArrayList here
ArrayList<String> strings = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 20; i++) {
strings.add(reader.readLine());
}
ArrayList<String> result = doubleValues(strings);
for (int i = 0; i < result.size(); i++) {
System.out.println(result.get(i));
}
}
public static ArrayList<String> doubleValues(ArrayList<String> list) {
//write your code here
for (int i = 0; i < list.size(); i=+2) {
list.add(i,list.get(i));
}
return list;
}
}