1 of 3

To do: November 4

Given an ArrayList named animals, using an Iterator remove all strings that begin with "c". Assume all strings have length of at least 1.

ArrayList<String> animals;

// assignment of variable animals not shown

// add code below

2 of 3

To do: November 4

ArrayList<String> animals;

// assignment of variable animals not shown

// add code below

Iterator<String> it = words.iterator();

while(it.hasNext())

{

String s = it.next();

if(s.charAt(0)=='c')

it.remove();

}

3 of 3

Homework

  • Complete Langton's project and submit - check rubric!
  • Repl.it 4-01.introIterators and 4-02.iterator vs for each