About 520,000 results
Open links in new tab
  1. How do you prompt a user for an input in java - Stack Overflow

    Nov 7, 2014 · "String" datatype in Java can hold both numbers and strings (as you asked). You can get user input using Scanner utility as below: Scanner input = new Scanner(); userChoice = input.nextLine(); // if it is a string //userChoice = input.nextInt(); // if it's integer choice

  2. Prompt for user yes or no input in Java - Stack Overflow

    Apr 19, 2015 · What do you exactly mean by "to loop the code yes to loop..."? Change while (true) with while (yn) so it will stop when he type "no", and change boolean yn; to boolean yn = true; And change the rules inside the cases too. yn = false; break; yn = true; break;

  3. Java User Input (Scanner class) - W3Schools

    To use the Scanner class, create an object of the class and use any of the available methods found in the Scanner class documentation. In our example, we will use the nextLine() method, which is used to read Strings: If you don't know what a …

  4. Window prompt() Method - W3Schools

    The prompt() method displays a dialog box that prompts the user for input. The prompt() method returns the input value if the user clicks "OK", otherwise it returns null.

  5. Java User Input – Scanner Class - GeeksforGeeks

    1 day ago · Java applications are called WORA (Write Once Run Anywhere). This means a programmer can develop Java code on one s. 7 min read. JDK in Java ... Java command-line argument is an argument i.e. passed at the time of running the Java program. In Java, the command line arguments passed from the console can be …

  6. How to Create a Console Prompt in Java that Waits for User Input …

    Learn how to implement a console prompt in Java that pauses execution until the user presses ENTER. Step-by-step guide with code snippets.

  7. Prompting - Modern Java

    To prompt a user for information you use the IO.readln function. IO.readln takes a String to output as a prompt. This will work the same as if the String was passed to IO.print. The program will then wait until a human types some text and clicks the enter key. Whatever they typed will be returned to the program as a String.

  8. How to prompt user input in a Java console application

    Discover how to effectively prompt and handle user input in Java console applications. Learn to use the Scanner class to capture various data types and create interactive experiences.

  9. java - The better way to ask for input? - Software Engineering …

    Dec 23, 2014 · public String getInput(String prompt) . System.out.print(prompt); return stdin.nextLine(); ... or. public static void main(String[] args) throws IOException. BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Input something: "); String name = stdin.readLine();

  10. Java Console Prompt for ENTER input before moving on

    I am creating a simply story, which will occasionally prompt the user to hit ENTER. It works the first time I prompt for it, but then it will immediately execute the other prompts, maybe because the program runs so fast by the time you let the ENTER key up, it …

  11. Some results have been removed