Java Reference
In-Depth Information
19 position
20 */
21 boolean hasNext();
22
23 /**
24 Adds an element before the iterator position
25 and moves the iterator past the inserted element.
26 @param element the element to add
27 */
28 void add (Object element);
29
30 /**
31 Removes the last traversed element. This method may
32 only be called after a call to the next() method.
33 */
34 void remove();
35
36 /**
37 Sets the last traversed element to a different
38 value.
39 @param element the element to set
40 */
41 void set(Object element);
42 }
681
682
S ELF C HECK
3. Trace through the addFirst method when adding an element to an empty
list.
4. Conceptually, an iterator points between elements (see Figure 3 ). Does
the position reference point to the element to the left or to the element to
the right?
5. Why does the add method have two separate cases?
Search WWH ::




Custom Search