?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

ArrayList Removing Integer Elements

APCSA-YZDLG3

Consider the following code.

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

What is printed as a result of executing the code?

A

[7, 5, 1, 3, 1]

B

[7, 5, 3]

C

[7, 1, 3, 1]

D

[7, 5, 3, 1]

E

[ ]