Collection size

Report a typo

In this problem, we will check your intuition about the behavior of collections.

What does the following code print?

ArrayList<Integer> numbers = new ArrayList<>();
System.out.print(numbers.size());

numbers.add(5);
numbers.add(4);
numbers.add(3);
System.out.print(numbers.size());

numbers.add(8);
numbers.add(1);
System.out.print(numbers.size());

Write the answer without any additional spaces.

Enter a short text
___

Create a free account to access the full topic