I'm trying to convert my String ArrayList into a Double ArrayList and for some reason it is not converting right.
My input:
1 2 3 4
My output:
[1.0]
[1.0, 1.0, 2.0]
[1.0, 1.0, 2.0, 1.0, 2.0, 3.0]
[1.0, 1.0, 2.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 4.0]
Expected Output:
[1.0] [1.0, 2.0] [1.0, 2.0, 3.0] [1.0, 2.0, 3.0, 4.0]
My Code
String inputValue;
List<String> input = new ArrayList<String>();
List<Double> numbers = new ArrayList<Double>();
while((inputValue = stdin.readLine()) != null) {
input.add(inputValue);
for(int i = 0; i < input.size(); i++) {
numbers.add (Double.parseDouble(input.get(i)));
}
System.out.println(numbers);
}