Java Scanner nextDouble() MethodThe nextDouble() is a method of Java Scanner class which is used to scan the next token of the input as a double. If the translation is successful, the scanner past the input that matched. SyntaxFollowing is the declaration of nextDouble() method: ParameterThis method does not accept any parameter. ReturnsThe nextDouble() method returns the double scanned from the input. ExceptionsInputMismatchException- It will thrown this Exception if the next token does not match the Float regular expression, or is out of range. NoSuchElementException- It will thrown this Exception if the input is exhausted. IllegalStateException- It will thrown this Exception if the innvocation is done after Scanner is closed. Compatibility VersionJava 1.5 and above Example 1Output: Enter the amount: 213734 Enter the Total Balance: 5684566.856 Left Balance is: 5470832.356 Example 2Output: Not Found Double:Hello Not Found Double:World! Found Double:12.0 Not Found Double:+ Found Double:13.0 Not Found Double:= Found Double:15.0 Not Found Double:2.123 Example 3Output: Enter value: 375437.565 Your entered Double value: 375437.565 Example 4Output: Enter the numeric value : 12345 Double value : 12345.0 Twice value : 24690.0 Next TopicJava-scanner-nextfloat-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India