About 334,000 results
Open links in new tab
  1. java - when to use while loop rather than for loop - Stack Overflow

    Use a DO loop when you don't know the number of iterations. If you don't know the start, stop, step or some combination of those then you need to use a DO loop. The expression will be …

  2. java - For loops vs. While loops - Stack Overflow

    Feb 21, 2014 · A for loop is a while loop. The only difference is that the for loop includes an initialize and state-change options, whereas a while loop requires you to do those separately. …

  3. Multiple and/or conditions in a java while loop - Stack Overflow

    Feb 17, 2016 · I want the while loop to execute when the user's input is a non-integer value, an integer value less than 1, or an integer value greater than 3. Once the input is valid, I will use …

  4. java - Strings and While loops - Stack Overflow

    Feb 19, 2012 · I think I'm having trouble with strings and while loops. When I run this program and I type in an action the program does nothing. It doesn't exit, it just sits there. That's why I think …

  5. How do I exit a while loop in Java? - Stack Overflow

    Dec 10, 2016 · To exit a while loop, use Break; This will not allow to loop to process any conditions that are placed inside, make sure to have this inside the loop, as you cannot place it …

  6. JAVA - using FOR, WHILE and DO WHILE loops to sum 1 through …

    Sep 17, 2012 · The Difference between While and Do-While is as Follows :-While is a Entry Control Loop, Condition is checked in the Beginning before entering the loop.-Do-While is a …

  7. java - Using switch statements in a while loop - Stack Overflow

    The solution: Get your next selection value from the Scanner object inside of the while loop. To understand this, think the problem out logically and be sure to walk through your code mentally …

  8. java - How can I input an if statement inside a while loop? - Stack ...

    Jul 30, 2016 · The problem is that if the num is negative, it won't go inside the while loop that is because before the while loop you have initialize i=1, since any negative number is lesser than …

  9. how can i use java scanner in while loop - Stack Overflow

    Nov 8, 2012 · You are trying to redeclare the variable inside the loop. You only want to give the existing variable a different value: while (question != 1) { System.out.println("Enter The Correct …

  10. java - How would I use a while loop to keep requesting user input ...

    Nov 5, 2018 · I've tried a couple of things with the while loop and can't seem to get it to work. I want to keep requesting user input until the user inputs the number 0, here is the code I have …

Refresh