online
The Java 2 Platform SpecificationBooks
Thinking in Java by Bruce EckelCore Java (TM) 2 Volume 1 - Fundamentals by Cay Horstmann and Gary Cornell
ListIterator listIteratorName = arrayListName.listIterator(); //creating a ListIterator for an ArrayList
ListIterator listIteratorName = linkedListName.listIterator(); //creating a ListIterator for a LinkedList
ListIterator listIteratorName = listName.listIterator(); //creating a ListIterator for a List
boolean areThereMore = listIteratorName.hasNext();
int whereIsNext = listIteratorName.nextIndex();
boolean wereThereAny = listIteratorName.hasPrevious();
int whereIsPrevious = listIteratorName.previousIndex();
ClassTypeToCastTo nextElement = (ClassTypeToCastTo) listIteratorName.next();
ClassTypeToCastTo previousElement = (ClassTypeToCastTo) listIteratorName.next();
arrayListName.add(elementToAdd); //inserts before what next() would return
arrayListName.set(intOffsetToSetElementAt, objectIn); //replaces element that was just returned by next() or previous(), // can not be called after add.
arrayListName.remove(intOffsetToRemoveElement); //deletes element that was just returned by next() or previous(), // can not be called after add.
ListIterator listIteratorName = arrayListName.listIterator();
while (listIteratorName.hasNext()) { classTypeToCastTo nextElement = (ClassTypeToCastTo) listIteratorName.next(); }
| Comments |
| Sign In |
| to add the first comment for Java ListIterators. |