Limited access

Upgrade to access all content for this subject

Before the loop begins, nums is an array list of integers which contains [40, 2, 30, 22, 55, 10].

for (int i=0; i<nums.size(); i++)
{
    nums.add(i, nums.remove(nums.size()-i-1));
}

What does nums contain after the segment of code is executed?

A

[10, 40, 2, 30, 22, 55]

B

[10, 55, 22, 30, 2, 40]

C

[10, 10, 10, 10, 10, 10]

D

[40, 2, 30, 22, 55, 10]

E

[]

Select an assignment template