Java Reference
In-Depth Information
Chapter
15
Iterators
Contents
What Is an Iterator?
The Interface
Iterator
Using the Interface
Iterator
A Separate Class Iterator
An Inner Class Iterator
A Linked Implementation
An Array-Based Implementation
Why Are Iterator Methods in Their Own Class?
The Interface
ListIterator
Using the Interface
ListIterator
An Array-Based Implementation of the Interface
ListIterator
The Inner Class
Java Class Library: The Interface
Iterable
Iterable
and for-each Loops
The Interface
List
Revisited
Prerequisites
Appendix E Exception Handling
Chapter
13
List Implementations That Use Arrays
Chapter
14
A List Implementation That Links Data
Objectives
After studying this chapter, you should be able to
•
Describe the concept of an iterator
•
Use an iterator to traverse or manipulate a list
•
Implement in Java a separate class iterator and an inner class iterator for a list
•
Describe the pros and cons of separate class iterators and inner class iterators