What is an Iterator?
Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator. Q: State the significance of public, private, protected, default modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers. A: public : Public class is visible in other packages, field is visible everywhere (class must be public too)private : Private variables or methods may be used only by an instance of the same class that declares the variable or method, A private feature may only be accessed by the class that owns the feature.protected : Is available to all classes in the same package and also available
Related Questions
- Should the Iterator that Graph.findPath returns be over a "list" of just vertices, or over an alternating "list" of vertex / edge (starting and ending with a vertex), as the textbook discusses paths?
- What is the advantage of using an Iterator compared to the get(index) method?
- WHAT IS AN ITERATOR? Name some TYPES OF ITERATORS?