About 68,000 results
Open links in new tab
  1. foreach - In detail, how does the 'for each' loop work in Java?

    People new to Java commonly encounter issues when trying to modify the original data using the new style foreach loop. Use Why doesn't assigning to the iteration variable in a foreach loop …

  2. Java 8 Iterable.forEach () vs foreach loop - Stack Overflow

    May 19, 2013 · The advantage of Java 1.8 forEach method over 1.7 Enhanced for loop is that while writing code you can focus on business logic only. forEach method takes …

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

    In Java 8 collection classes that implement Iterable (for example, all List s) now have a forEach method, which can be used instead of the for loop statement demonstrated above.

  4. How do I get the current index/key in a "for each" loop

    16 In Java, you can't, as foreach was meant to hide the iterator. You must do the normal For loop in order to get the current iteration.

  5. Break or return from Java 8 stream forEach? - Stack Overflow

    When using external iteration over an Iterable we use break or return from enhanced for-each loop as:

  6. java - How to for each the hashmap? - Stack Overflow

    300 Lambda Expression Java 8 In Java 1.8 (Java 8) this has become lot easier by using forEach method from Aggregate operations (Stream operations) that looks similar to iterators from …

  7. How do I efficiently iterate over each entry in a Java Map?

    In Java 1.8 (Java 8) this has become lot easier by using forEach method from Aggregate operations (Stream operations) that looks similar to iterators from Iterable Interface.

  8. Foreach loop in java for a custom object list - Stack Overflow

    I am not a keen user of java but I know in many other programming languages a foreach loop would be the most simple way of doing this. After a bit of research I found the following link …

  9. How to Iterate over a Set/HashSet without an Iterator?

    Perhaps one should pick a more adequate data structure in that case? A set's not designed to iterate over efficiently. Why not use an ArrayList and iterate over it with a standard for loop? …

  10. Calling remove in foreach loop in Java - Stack Overflow

    Closed 10 years ago. In Java, is it legal to call remove on a collection when iterating through the collection using a foreach loop? For instance: