← Unit 4 · all exercises
Saved in this browser only

Double every number

Return a new ArrayList holding every number from the original, doubled, in the same order. Leave the original alone.

java.util.ArrayList<Integer> doubled(java.util.ArrayList<Integer> list)

Solution.java
Loading editor…
Results

Examples

  • Solution.doubled(new java.util.ArrayList<>(java.util.List.of(1, 2, 3))).toString() → [2, 4, 6]
  • Solution.doubled(new java.util.ArrayList<Integer>()).toString() → []

There are also 2 hidden tests you can't see. Solve the problem, not the examples.