Presentation is loading. Please wait.

Presentation is loading. Please wait.

Iterator.

Similar presentations


Presentation on theme: "Iterator."— Presentation transcript:

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


Download ppt "Iterator."

Similar presentations


Ads by Google