About 228,000 results
Open links in new tab
  1. java.util.scanner - How can I read input from the console using the ...

    This Scanner class comes under java.util, hence the first line of the program is import java.util.Scanner; which allows the user to read values of various types in Java.

  2. java - Getting Keyboard Input - Stack Overflow

    Jul 9, 2013 · Scanner package used for obtaining the input of the primitive types like int, double etc. and strings. It is the easiest way to read input in a Java program, though not very efficient. …

  3. java - Scanner is skipping nextLine () after using next () or nextFoo ...

    Aug 14, 2011 · That's because the Scanner.nextInt method does not read the newline character in your input created by hitting "Enter" and so the call to Scanner.nextLine returns after reading …

  4. How to read integer value from the standard input in Java

    Mar 24, 2010 · The question is "How to read from standard input". A console is a device typically associated to the keyboard and display from which a program is launched. You may wish to …

  5. java - How to use Scanner to accept only valid int as input - Stack ...

    Use Scanner.hasNextInt(): Returns true if the next token in this scanner's input can be interpreted as an int value in the default radix using the nextInt() method.

  6. java - Take a char input from the Scanner - Stack Overflow

    Dec 19, 2012 · Scanner reader = new Scanner(System.in); char c = reader.nextChar(); This method doesn't exist. I tried taking c as a String. Yet, it would not always work in every case, since the …

  7. How to get the user input in Java? - Stack Overflow

    Mar 13, 2011 · I attempted to create a calculator, but I can not get it to work because I don't know how to get user input. How can I get the user input in Java?

  8. Java using scanner with try-with-resources - Stack Overflow

    Dec 1, 2017 · Input: java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1540) at …

  9. java - Using scanner.nextLine () - Stack Overflow

    The line String sentence = scanner.nextLine(); waits for input to be entered before continuing on to System.out.print("Enter an index:\t");. This produces the output:

  10. Validating input using java.util.Scanner - Stack Overflow

    I'm taking user input from System.in using a java.util.Scanner. I need to validate the input for things like: It must be a non-negative number It must be an alphabetical letter ... etc What's the …