Only displaying the Strings is wrong.. Where is the mistake?
Thanks for help
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
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String s = reader.readLine();
if (s.isEmpty())
break;
System.out.println(list.add(s));
}
ArrayList<String> result = doubleValues(list);
for (String x : result){
System.out.println(x);
}
// Display result
}
public static ArrayList<String> doubleValues(ArrayList<String> list) {
//write your code here
//int x = list.size() - 1;
for (int i = 0; i < list.size() ; i++) {
list.add(i+1,list.get(i));
i++;
}
return list;
}
}