About 200,000 results
Open links in new tab
  1. java - Remove elements from collection while iterating - Stack …

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

  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 exit a while loop in Java? - Stack Overflow

    Oct 31, 2011 · 2 Take a look at the Java™ Tutorials by Oracle. But basically, as dacwe said, use break. If you can it is often clearer to avoid using break and put the check as a condition of the …

  4. java - How to break a while loop from an if condition inside the …

    An "if" is not a loop. Just use the break inside the "if" and it will break out of the "while". If you ever need to use genuine nested loops, Java has the concept of a labeled break. You can put a …

  5. java - when to use while loop rather than for loop - Stack Overflow

    I am learning java as well android. Almost everything that we can perform by while loop those things we can do in for loop. I found a simple condition where using while loop is better than …

  6. While loops with Sentinels for Java - Stack Overflow

    Oct 4, 2016 · I am writing the following program using while loops with sentinels. The problems I am having include: (1) Discovering how to obtain the "smallest score" entered without the …

  7. Is it possible to declare a variable within a Java while conditional ...

    Aug 4, 2016 · But the variable still has to be declared outside the while-loop. So, as I want to keep my variable scopes clean, is it possible to declare a variable within the while conditional, or is …

  8. Using while loop in java - Stack Overflow

    Here's a simple change, instead of using a while loop, you could try using a do while loop! I know this is late, but I'm learning along the way and I'm taking this as a practise!

  9. What condition does while(true) test? When is it true and false?

    Sometimes the exit condition from a loop is complicated, such as in a server that is expected to constantly wait for and process input, until it receives a signal to shut down. In such cases, …

  10. java - How to skip a iteration/loop in while-loop - Stack Overflow

    Feb 13, 2013 · Unlike the break keyword, continue does not terminate a loop. Rather, it skips to the next iteration of the loop, and stops executing any further statements in this iteration. This …