Download presentation
Presentation is loading. Please wait.
1
Iterator
2
iterator is an object that traverse a container, like string or lists.
The most fundamental methods provided by an iterator are hasNext(), which returns a boolean value indicating whether the container has more elements or not, and next(), which returns an element in that container, and then move to the next. Java has a built-in iterator class and many classes, like arrayList, have an associated iterator.
3
Loop through a list Useful info:
Java provides a simpler way to loop through a list, the for each loop The common usage is like for(datatype element: list){ (loop body) } Useful info: de/language/foreach.html
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.