About 5,950,000 results
Open links in new tab
  1. 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 - Declaring variables inside or outside of a loop - Stack Overflow

    Jan 10, 2012 · The scope of local variables should always be the smallest possible. In your example I presume str is not used outside of the while loop, otherwise you would not be asking …

  3. How do I break out of nested loops in Java? - Stack Overflow

    May 20, 2009 · By having flag variable ,We can easily control execution of any number of loops ,Just we need to keep this flag value check at loop condition statement as done in main loop …

  4. java - How to make a reverse string using a for loop? - Stack …

    Apr 1, 2017 · I need to have my code output the String in reverse order. For example, the output should have "code" return as "edoc". This is what I have done so far. public String …

  5. What is the syntax of the enhanced for loop in Java?

    Mar 2, 2017 · I have been asked to use the enhanced for loop in my coding. I have only been taught how to use traditional for loops, and as such don't know about the differences between …

  6. java - What is the difference between i++ & ++i in a for loop?

    The way for loop is processed is as follows 1 First, initialization is performed (i=0) 2 the check is performed (i < n) 3 the code in the loop is executed. 4 the value is incremented 5 Repeat steps …

  7. Breaking out of a for loop in Java - Stack Overflow

    Mar 7, 2013 · In my code I have a for loop that iterates through a method of code until it meets the for condition. Is there anyway to break out of this for loop? So if we look at the code below, …

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

    May 19, 2013 · Which of the following is better practice in Java 8? Java 8: joins.forEach(join -> mIrc.join(mSession, join)); Java 7: for (String join : joins) { mIrc.join(mSession, join); } I have …

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

    Foreach loop in java for a custom object list Asked 12 years, 11 months ago Modified 3 years, 7 months ago Viewed 173k times

  10. Is there a shorter way to write a for loop in Java?

    4 There is a way to write shorter for loop. If "for" loop is the concern, you may find this interesting for(int i = -1; ++i < max;) { //do something } Notice that the counter increment was done before …