About 53,600,000 results
Open links in new tab
  1. java - How do I read input that could be an int or a double?

    Jul 27, 2015 · Scanner input = new Scanner(System.in); double choice = input.nextDouble(); Then, if you need to know whether you've gotten a double or not, you can check it using …

  2. Scanner nextDouble() method in Java with Examples

    Oct 12, 2018 · The nextDouble () method of java.util.Scanner class scans the next token of the input as a Double. If the translation is successful, the scanner advances past the input that …

  3. How to make user input in java be of the type double?

    Aug 6, 2012 · try { double var = sc.nextDouble(); } catch(TypeMismatchException ex) { System.err.println("try again, wrong type"); } basically, if there is an error storing the value in a …

  4. formatting - Java double input - Stack Overflow

    Aug 19, 2012 · final Scanner input = new Scanner(System.in); final Pattern pattern = Pattern.compile("\\d+\\.\\d{2}?"); while (input.hasNext()) { …

  5. Java Scanner nextDouble() Method - W3Schools

    The nextDouble() method returns a double value containing the number represented by the next token. The scanner is able to interpret digit groupings, such as using a comma for separating …

  6. Java Scanner nextDouble ()

    The nextDouble() method of the Scanner class in Java is used to obtain the input as a double. This method parses the next token of the input as a double value. Syntax: public double …

  7. Java User Input – Scanner Class - GeeksforGeeks

    3 days ago · 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. How to Get User Input in Java

    Learn how to get user input in Java using Scanner class and other methods. Step-by-step guide with code examples to take input from the console efficiently.

  9. How to Use the Java Scanner nextDouble() Method - JavaBeat

    Aug 31, 2023 · The “nextDouble()” method of the “java.util.Scanner” class scans the next input token as a Double and throws the “InputMismatchException”, “NoSuchElementException”, and …

  10. java - how do i make the user input a double? - Stack Overflow

    Jul 8, 2022 · how do i make the user input a double? You did this part fine - scanner.nextDouble() is all it takes. Here's a really simple standalone example, including output: …

  11. Some results have been removed
Refresh