To loop through a collection, use the hasNext()
and next()
methods of the Iterator
:
Example
while(it.hasNext()) {
System.out.println(it.next());
}
Practice Excercise Practice now
To loop through a collection, use the hasNext()
and next()
methods of the Iterator
:
while(it.hasNext()) {
System.out.println(it.next());
}
Practice Excercise Practice now