Package utilities
Class MyArrayList.MyIterator<E>
java.lang.Object
utilities.MyArrayList.MyIterator<E>
- Type Parameters:
E
- The type of elements in this list.
- All Implemented Interfaces:
Iterator<E>
- Enclosing class:
MyArrayList<E>
A custom Iterator implementation for
MyArrayList
.-
Field Summary
-
Constructor Summary
ConstructorDescriptionMyIterator
(MyArrayList<E> list) Initializes a new instance ofMyArrayList.MyIterator
. -
Method Summary
-
Field Details
-
list
-
currentIndex
private int currentIndex
-
-
Constructor Details
-
MyIterator
Initializes a new instance ofMyArrayList.MyIterator
.
-
-
Method Details
-
hasNext
public boolean hasNext()Description copied from interface:Iterator
Returnstrue
if the iteration has more elements. (In other words, returnstrue
ifnext()
would return an element rather than throwing an exception.) -
next
Description copied from interface:Iterator
Returns the next element in the iteration.- Specified by:
next
in interfaceIterator<E>
- Returns:
- The next element in the iteration.
- Throws:
NoSuchElementException
- If the iteration has no more elements.
-