hi everyone,
I think my code is right but I cannot do that the 3th will be match. What am I doing wrong?
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();
list.add(S);
}
ArrayList<String> result = doubleValues(list);
for (String input: result){
System.out.println(input);
}
// Display result
}
public static ArrayList<String> doubleValues(ArrayList<String> list) {
//write your code here
ArrayList<String> result = new ArrayList<String>();
for(int j=0; j<10; j++){
result.add(list.get(j));
result.add(list.get(j));
}
return result;
}
}