Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 11. The Collections Framework > Iterating Over a Collection with Iterat...

Iterating Over a Collection with Iterator and for

When programming with Collection, iterating over it is one of the most common tasks around. There are two ways to do this: by using Iterator and by using for.

Recall that Collection extends Iterable, which has one method: iterator. This method returns a java.util.Iterator that you can use to iterate over the Collection. The Iterator interface has the following methods:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial