?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Easy

ArrayList Removing an Integer Element

APCSA-V2YVGL

Consider the following code segment.

ArrayList<Integer> list = new ArrayList<Integer>();
list.add(7);
list.add(5);
list.add(1);
list.add(3);
list.add(1);
list.remove(1);
System.out.print(list);

What is printed as a result of executing the code segment?

A

[7, 5, 1, 3, 1]

B

[7, 5, 3]

C

[7, 1, 3, 1]

D

[7, 5, 3, 1]

E

[ ]