About 2,160,000 results
Open links in new tab
  1. 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.

  2. 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 …

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

    Feb 13, 2017 · the forEach you have mentioned is same as set.forEach(System.out::println); as we are dealing with lamda expression/function interface which means interface with only 1 …

  4. java - Modifying local variable from inside lambda - Stack Overflow

    May 4, 2015 · Then using Java 8 "forEach", I iterate over the list field, and when the object I want is found, I assign that object to the output field. So this assigns a value to a field of the local …

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

    May 19, 2013 · Calling a single function more cleanly by using forEach() and a method reference argument (ie, list.forEach (obj::someMethod)). However, keep in mind the points on checked …

  6. 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.

  7. Loop (for each) over an array in JavaScript - Stack Overflow

    Feb 17, 2012 · forEach accepts a callback function and, optionally, a value to use as this when calling that callback (not used above). The callback is called for each element in the array, in …

  8. Как работает цикл foreach в Java? - Stack Overflow на русском

    Как работает цикл foreach в Java? Вопрос задан 6 лет 8 месяцев назад Изменён 6 лет 2 месяца назад Просмотрен 26k раз

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

    If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map? Will the ordering of

  10. Java Foreach with a condition - Stack Overflow

    Apr 11, 2012 · 8 No, foreach is specially designed only for iterating all the elements of an array or collection. If you want you can check condition inside it and use break keyword for getting out …