About 3,710,000 results
Open links in new tab
  1. how can i use java scanner in while loop - Stack Overflow

    Nov 8, 2012 · Scanner sc = new Scanner(System.in); System.out.println("Enter The Correct Number!"); int question = sc.nextInt(); while (question != 1) { System.out.println("please try …

  2. java - do while loop with input scanner - Stack Overflow

    Dec 14, 2014 · public class JavaApplication8 { static String type; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); do { System.out.println("Press Y to get …

  3. java - Creating a loop with a Scanner - Stack Overflow

    Sep 8, 2014 · You could use a while loop such as the following one: Scanner scanner = new Scanner(System.in); int x = scanner.nextInt(); while (x > 0){ // do something x--; } Alternatively …

  4. How to Efficiently Run a Scanner in a While Loop in Java

    Discover how to solve the common issue of running a Scanner in a while loop in Java effectively. This guide provides a clear solution and examples to ensure ...

  5. How to Implement a while Loop with Scanner in Java for

    Learn how to create a loop in Java that accepts user input, sums numbers until it reaches 100, and handles exceptions.---This video is based on the question ...

  6. Java while Loop - GeeksforGeeks

    Nov 11, 2024 · Java while loop is a control flow statement used to execute the block of statements repeatedly until the given condition evaluates to false. Once the condition becomes …

  7. Java User Input – Scanner Class - GeeksforGeeks

    Apr 22, 2025 · Import the Scanner class using import java.util.Scanner; Create the Scanner object and connect Scanner with System.in by passing it as an argument i.e., Scanner sc = new …

  8. Java Scanner tutorial with while and for loops - YouTube

    Mar 18, 2021 · Learn how to use Java's Scanner to get user input, iterate over an input String, and continue prompting for input until the user is done.

  9. Java While Loop - W3Schools

    Loops can execute a block of code as long as a specified condition is reached. Loops are handy because they save time, reduce errors, and they make code more readable. The while loop …

  10. java - Scanner inside while loop - Stack Overflow

    Apr 22, 2015 · I need to create a simple game where a random number is created, and the user has to guess the number by inputting numbers into a scanner. If their guess is too high, the …

  11. Some results have been removed