SYSC 2100 Lecture Notes - Lecture 7: Iterator, Foreach Loop, Random Access
Both hierarchies have an interface at the top, abstract classes in between, and a fully defined class at the bottom. Classes that have undefined methods (like an interface) as well as defined methods (like a regular class) An abstract class, unlike an interface, provides simple definitions of methods that need not be overridden in the fully defined subclass. The benefit is that a subclass of abstractcollection need not override isempty() The collection interface includes method headings for inserting, removing and searching for an element in a collection. An iterator is an object that allows a user to loop through a collection without accessing the fields. Associated with each class that implements the collection interface, there is an iterator class that implements the following interface: - 2 // returns true if this iterator object is positioned. 6 // returns the element this iterator object is. 7 //positioned at, and advances this iterator object.