← Unit 4 · all exercises
Saved in this browser only

From an array to a list

Return an ArrayList holding the same numbers as the array, in the same order.

java.util.ArrayList<Integer> toList(int[] values)

Solution.java
Loading editor…
Results

Examples

  • Solution.toList(new int[]{1, 2, 3}).toString() → [1, 2, 3]
  • Solution.toList(new int[]{}).toString() → []

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