?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Adding Characters from Flowerbed String to ArrayList

APCSA-AVYXLP

Consider the following code segment .

ArrayList<String> list = new ArrayList<String>();
String word = "flowerbed";
for (int i=0; i<word.length()-1; i++)
{
    list.add(word.substring(i,i+2));
    if (i%3==0)  
        i++;
}

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

A

[f, o, w, r, b]

B

[fl, lo, ow, we, er, rb, be, ed]

C

[flo, wer, bed]

D

[fl, ow, we, rb, be]

E

[f, l, o, w, e, r, b, e, d]