Monthly Archives: September 2016

Iterator and ReverseArrayIterator

September 30th, 2014

Classwork:
Visit the Classroom Salon
1. How does an iterator compare to a for each construct?
2. What must a collection implement to an iterable collection?
3. What methods must the Iterator class include? Elaborate your answer.
4. What mechanism does java use to enable/enforce the implementation of these methods?
5. Why are Iterators generic?
6. How is the ReverseArrayIterator implemented?
7. What is an iterator?
8. What is the implementation of the Iterator interface?
9. How is the ReverseArrayIterator implemented?
10. Why are the methods implemented in a nested class within client classes?
11. What two cases should throw exceptions to conform to the Iterator specification?
12. Why aren’t these two exceptions implemented?
13. Is it necessary to import Iterable? Iterator?

Homework:
Write a stack client Parentheses.java that reads in a text stream from standard input and uses a stack to determine whether its parentheses are properly balanced. For example, your program should print true for [()]{}{[()()]()} and false for [(]).