It's returning proper string twice in new lines, then what's the issue?
package com.codegym.task.task07.task0717;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Duplicating words
1. Read 10 words from the keyboard and add them to a list of strings.
2. The doubleValues method should duplicate words like this:
alpha, beta, gamma, -> alpha, alpha, beta, beta, gamma, gamma.
3. Display the result, each value on a new line.
*/
public class Solution {
public static void main(String[] args) throws Exception {
// Read strings from the console and declare an ArrayList here
ArrayList<String> input = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0; i < 10; i++) {
String s = reader.readLine();
input.add(s);
}
ArrayList<String> result = doubleValues(input);
// Display result
}
public static ArrayList<String> doubleValues(ArrayList<String> list) {
//write your code here
for(int i = 0; i < 10; i++) {
System.out.println(list.get(i));
System.out.println(list.get(i));
}
return null;
}
}