About 51 results
Open links in new tab
  1. java - Difference between Iterator and Listiterator ... - Stack Overflow

    Jun 11, 2012 · ListIterator listiterator = List.listIterator(); i.e., we can't get ListIterator object from Set interface. Reference : - What is the difference between Iterator and ListIterator ?

  2. loops - Ways to iterate over a list in Java - Stack Overflow

    EDIT: As @iX3 points out in a comment, you can use a ListIterator to set the current element of a list as you are iterating. You would need to use List#listIterator() instead of List#iterator() to initialize the …

  3. java - How To Use ListIterator? - Stack Overflow

    Apr 16, 2017 · ListIterator<E> List.listIterator(int index) Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list. which essentially starts your list …

  4. Iterating through a list in reverse order in java - Stack Overflow

    20 Java 21 added a reversed() method to List, which returns a reversed view of the list. This can be used to iterate in reverse order.

  5. list - Java - ListIterator and hasNext - Stack Overflow

    Jun 14, 2013 · I'm studying Java, and I've a problem with ListIterator. I've a List with these characters: b u o n g i o r n o. My code returns "buongiorno", while I was expecting it to print "buongiorn", without...

  6. java - Reset list iterator to first element of the list - Stack Overflow

    LinkedList<String> list; Iterator iter=list.listIterator; iter.next(); iter.next(); Over and over again and after many moves of the iterator, I need to "reset" the position of the iterator. I want to ask how I can …

  7. Add elements to a List while iterating over it. (Java)

    You can't modify a Collection while iterating over it using an Iterator, except for Iterator.remove(). However, if you use the listIterator() method, which returns a ListIterator, and iterate over that you …

  8. Java - ListIterator Implementation Specifics - Stack Overflow

    Dec 7, 2013 · I have a quick question about how ListIterators (and, I guess, Iterators in general) perform in Java. For, say, a Linked List (Java's standard one), if I get a ListIterator for it, does it loop thr...

  9. Trying to remove an object with list iterator - Stack Overflow

    Apr 18, 2013 · Use the remove () method of the ListIterator (at most once for each next ()) Use another List implementation, like CopyOnWriteArrayList, wich is garanteed never to throw an …

  10. java - How do I refer to the current object in an iterator - Stack Overflow

    How do I refer to the current object in an iterator For the record, the Iterator API does not allow you to do this. There is no notion of a "current" object. The Iterator.next() method gives you the next object ...