How do you traverse through a collection using its Iterator?5
614 5b5cc7cee4d2b4197775111a
Q: How do you traverse through a collection using its Iterator?
- Show Answer
- Workspace
- Discuss
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().
Similar Questions
Since Nithya and Suganya exchange places, so Rita’s new position is the same as Monika’s earlier position. This position is 17th from the right and 10th from the left. Therefore Number of girls in the row = (16 + 1 + 9) = 26.