← Unit 4 · all exercises
Saved in this browser only

How many in the list

Return how many items the list holds. An ArrayList uses size(), not length.

int size(java.util.ArrayList<Integer> list)

Solution.java
Loading editor…
Results

Examples

  • Solution.size(new java.util.ArrayList<>(java.util.List.of(1, 2, 3))) → 3
  • Solution.size(new java.util.ArrayList<Integer>()) → 0

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