About 309,000 results
Open links in new tab
  1. How to get the user input in Java? - Stack Overflow

    Mar 13, 2011 · You can make a simple program to ask for user's name and print what ever the reply use inputs. Or ask user to enter two numbers and you can add, multiply, subtract, or divide those numbers and print the answers for user inputs just like a behavior of a calculator. So there you need Scanner class.

  2. How do you prompt a user for an input in java - Stack Overflow

    Nov 7, 2014 · Having imported java.util.Scanner, to get input from the user as a String, create a Scanner object that parameterizes System.in and assign userChoice the value of nextLine() invoked by the Scanner object: Scanner input = new Scanner(System.in); String userChoice = input.nextLine(); A few things about your code.

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

    Nov 5, 2018 · Using the while loop to ask user their input in JAVA. 0. while() loop for user input. 3.

  4. java - How to get boolean user input using scanner ... - Stack …

    Feb 6, 2015 · So i have to ask the user whether they are above 18 and they have to answer with a true or false. And keep looping until they enter the right input So far, i have this boolean b = false; do { ...

  5. Have java find/read a file from user input? - Stack Overflow

    Oct 28, 2013 · // Scanner Object to be used for the user file path input Scanner keyboard = new Scanner(System.in); // Asks the user to enter the full path of their file System.out.print("Enter your full file path: "); // Stores the user input file path as a string String filename = keyboard.nextLine(); // Creates a File object for the file path, and scans it ...

  6. Using the while loop to ask user their input in JAVA

    Nov 12, 2013 · I have like 3 hours trying to solve this simple problem. Here is what I am trying to accomplished: Ask the user to enter a number, and then add those numbers. If the users enters five numbers, the...

  7. Java: How to ask user if he/she wants to continue program

    Oct 1, 2013 · I've already made it so that it will tell whether the input from the user is a prime number or not a prime number but now I have to make it so that it will ask the user if he/she wants to check another number and wait for the user to enter "Y" or "y" as yes, "n" or "N" as no. If yes, repeat the three steps. If no, exit the program.

  8. How to set a date as input in java? - Stack Overflow

    Dec 20, 2014 · tl;dr LocalDate.of( 2026 , 1 , 23 ) // Pass: ( year , month , day ) java.time. Some other Answers are correct in showing how to gather input from the user, but use the troublesome old date-time classes that are now legacy, supplanted by the java.time classes.

  9. java.util.scanner - How to answer a question with a string using the ...

    Feb 13, 2011 · If you don't want to encode all the actual word solutions (like "Lincoln") you can also just ask the user to pick a number/letter solution since you only have 3. Scanner input = new Scanner(System.in); System.out.println("Who is on the 5 dollar bill? 1. Lincoln 2. Somebody 3.

  10. java - How to collect input from user with dialog box? - Stack …

    Oct 26, 2013 · "Ask the user to input a number. You should use an input dialog box for this input. Be sure to convert the String from the dialog box into a real number. The program needs to keep track of the smallest number the user entered as well as the largest number entered. Ask the user if they want to enter another number. If yes, repeat the process.

Refresh