About 3,010,000 results
Open links in new tab
  1. Can we write our own iterator in Java? - Stack Overflow

    Mar 5, 2014 · If you're using an existing iterable object (say, a LinkedList) from java.util, you'll need to either subclass it and override its iterator function so that you return your own, or …

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

    The enhanced for loop is just a syntactic shortcut introduced in Java 5 to avoid the tedium of explicitly defining an iterator. For both styles, you can come up with essentially trivial variations …

  3. Java: Get first item from a collection - Stack Overflow

    Nov 4, 2009 · Invoking this method does instantiate the Iterator object, but that is really the only overhead (not like copying all the elements). For example, looking at the type returned by the …

  4. java - How does next() method on iterators work? - Stack Overflow

    Dec 6, 2017 · Let's take a closer look at how the method is implemented. Therefore we will first see what ArrayList#iterator does. Take a look at its source code: public Iterator<E> iterator() { …

  5. java - Iterate through a HashMap - Stack Overflow

    Jul 1, 2009 · Java 8 syntax. May still not work for Android development. "Android is not intended to be 100% compatible with any Java SE API version, not 6 nor 8 nor any. ... The JRE is the …

  6. Difference between Iterator and Spliterator in Java8

    Jul 21, 2018 · An Iterator always has an unknown size: you can traverse elements only via hasNext/next; a Spliterator can provide the size (thus improving other operations too …

  7. Iterating through a list in reverse order in java

    Mar 19, 2015 · EDIT: Option 3: As others have suggested, you could write an Iterator that will go through the list in reverse, here is an example:

  8. performance - Java - When to use Iterators? - Stack Overflow

    Apr 1, 2010 · If it also lends itself to the Iterator interface, then it seems like a win. I was reading a little bit that there is a lot of overhead with using an Iterator. A good example of where I used …

  9. java - What is the difference between iterator and iterable and …

    Jul 28, 2011 · Iterable present in java.ḷang package Iterator present in java.util package. Contains only one method iterator() Contains three method hasNext(), next(), remove() Introduced in 1.5 …

  10. How do I iterate and modify Java Sets? - Stack Overflow

    Java calls this "fail-fast" iteration: i.e. there are some actions, usually those that modify an Iterable instance (while an Iterator is iterating over it). The "fail" part of the "fail-fast" notion refers to the …

Refresh