← Unit 4 · all exercises
Saved in this browser only

Take a value out

Return a new ArrayList holding everything from the original except the value given. Every copy of it goes.

java.util.ArrayList<Integer> without(java.util.ArrayList<Integer> list, int value)

Solution.java
Loading editor…
Results

Examples

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

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