Join Examsbook
606 0

Q: How do you traverse through a collection using its Iterator?

  • Show AnswerHide Answer
  • Workspace

Answer :
Explanation :

To use an iterator to traverse through the contents of a collection, follow these steps: - Obtain an iterator to the start of the collection by calling the collections iterator() method. - Set up a loop that makes a call to hasNext(). Have the loop iterate as long as hasNext() returns true. - Within the loop, obtain each element by calling next().

Are you sure

  Report Error

Please Enter Message
Error Reported Successfully