Removal Rights During a Traversal

A mutable Java ArrayList named values initially contains the record identifiers 11, 22, 33 and 44, in that order. A fresh iterator it traverses this list and supports remove().


Execute the operations in the table sequentially using this same iterator. No other code modifies the list. If an operation throws an exception, the test harness catches it and continues with the next row. A rejected removal leaves both the list and the iterator's state unchanged.


Complete both columns for every operation. For an operation's outcome, enter its returned integer or lowercase boolean, done for a successful void method, or the exact exception class name. Enter each list size as an exact integer number of records immediately after that operation.

OperationOutcomeList size
it.next()
it.remove()
it.hasNext()
it.remove()
it.next()
it.next()
it.remove()
it.next()
it.hasNext()
it.remove()

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Iterable and Iterator Questions: