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

    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 change the …

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

    3 In java 8 you can use List.forEach() method with lambda expression to iterate over a list.

  3. 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 java.util.function.Consumer …

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

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

  5. How to use if-else logic in Java 8 stream forEach

    The problem by using stream().forEach(..) with a call to add or put inside the forEach (so you mutate the external myMap or myList instance) is that you can run easily into concurrency issues if someone …

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

    Foreach loop in java for a custom object list Asked 13 years, 1 month ago Modified 3 years, 9 months ago Viewed 174k times

  7. How do I apply the for-each loop to every character in a String?

    Mar 16, 2010 · If you use Java 8 with Eclipse Collections, you can use the CharAdapter class forEach method with a lambda or method reference to iterate over all of the characters in a String.

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

  9. java foreach skip first iteration - Stack Overflow

    Is there an elegant way to skip the first iteration in a Java5 foreach loop ? Example pseudo-code: for ( Car car : cars ) { //skip if first, do work for rest . . }

  10. java - Remove elements from collection while iterating - Stack Overflow

    May 3, 2012 · Actually the java docs on this are really confusing. "Iterators allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics."