About 3,100,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. loops - Ways to iterate over a list in Java - Stack Overflow

    9 In Java 8 we have multiple ways to iterate over collection classes. Using Iterable forEach The collections that implement Iterable (for example all lists) now have forEach method. We can …

  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 …

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

    Feb 17, 2012 · It doesn't get simpler than that! Under the covers, that gets an iterator from the array and loops through the values the iterator returns. The iterator provided by arrays …

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

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

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

    Most attempts to solve a problem with forEach rather than one of the other terminal operations are loops in disguise and would work better with a loop. In example code (like on Stackoverflow) …

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

  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 do I write a generic foreach loop in Java? - Stack Overflow

    You can do foreach with either an iteratable or array. Be aware that if you don't typecheck your iterator (Iterator), then you need to use Object for ObjectType.

  10. Why can't I use foreach on Java Enumeration? - Stack Overflow

    The new-style-for-loop ("foreach") works on arrays, and things that implement the Iterable interface. It's also more analogous to Iterator than to Iterable, so it wouldn't make sense for …