In our experience, the biggest problem encountered by users of generic classes and methods are syntax errors. We hope that lab activities alerted you to the problems.
Various aspects of iterators cause trouble, mainly with the maintenance of the internal state of the iteration. The constructor initializes the state, typically to the position of the first item to be enumerated. Subsequent processing maintains a data invariant that relates the position of the most recently returned element to the number of items in the collection being enumerated. And a detail: the
hasNextmethod should never change the state of the iterator.
Submit the following files as
Read the following:
- JRS: Packages (optional)
Don't forget to work on your project and study for the midterm!