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 r = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
for (int i=0; i<10; i++)
list.add(r.readLine());
ArrayList<String> result = doubleValues(list);
for (String x : list)
System.out.println(x);
// Display result
}
public static ArrayList<String> doubleValues(ArrayList<String> list) {
//write your code here
//ArrayList<String> st = new ArrayList<String>();
for(int i=0; i<list.size(); i+=2)
list.add(i, list.get(i));
return null;
}
}
correct output
Resolved
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Adarsh
5 June 2020, 02:47
on line 35 you should return list instead of null.
0
Rich
31 May 2020, 04:18
ah thank you.
0
Brandon
31 May 2020, 04:06
It does seem to work..however I'd wager they want you to use the returned result of the method "doubleValues". Yours returns null, and your "ArrayList<String> result" is never used.
+1