About 23,000 results
Open links in new tab
  1. How to make user input in java be of the type double?

    Aug 6, 2012 · You are using a double i in your for-loop for being the array index, when you read in the array index to int n. That's where your Type Mismatch error is coming from. As array …

  2. 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 …

  3. 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()) { …

  4. Java User Input (Scanner class) - W3Schools

    Java User Input. The Scanner class is used to get user input, and it is found in the java.util package. To use the Scanner class, create an object of the class and use any of the available …

  5. 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 …

  6. Scanner Class in Java (With Examples) - Scaler Topics

    Aug 2, 2021 · We can do this in Java using the Scanner class, which allows us to take input from all in-built data types in Java, such as boolean, int, etc. Suppose you are writing a Java …

  7. Java Data Types - GeeksforGeeks

    Apr 7, 2025 · 7. double Data Type . The double data type is a double-precision 64-bit IEEE 754 floating-point. For decimal values, this data type is generally the default choice. The size of the …

  8. Java User Input - Multiple Ways [Easy Examples] - GoLinuxCloud

    Sep 7, 2022 · In java, we have three different kinds of methods through which we can take inputs from the user. In this tutorial, we will learn about different methods that are available in java to …

  9. Scanner Class in Java - GeeksforGeeks

    Apr 11, 2025 · In Java, the Scanner class is present in the java.util package is used to obtain input for primitive types like int, double, etc., and strings. We can use this class to read input …

  10. 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 …