Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Define the Iterator class, and hasNext() and next() methods */
- private class LinkedListIterator implements Iterator<Item> { // 1
- Node<Item> current = head; // 2
- public boolean hasNext() { // 3
- return current != null; // 3
- } // 3
- public Item next() { // 4
- Item item = current.data; // 4
- current = current.next; // 4
- return item; // 4
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement