Solution to 735a: Generic iterators
See code at solutions/code/tutorialquestions/question735a
Making the iterator classes of question 1486 and question 8a61 generic is fairly straightforward: it basically just involves stripping out specific types and replacing them with generic ones. Compare the sample solutions to see this.
Extension: The sample solution provides a unifying interface, GenericCollection
, that offers the iterator()
method, and the GenericStack
and GenericSet
interfaces both extend GenericCollection
.