Java Scanner nextBigDecimal() MethodThe nextBigDecimal() is a method of Java Scanner class which scan the next token of the input as a BigDecimal. SyntaxFollowing is the declaration of nextBigDecimal() method: ParameterThis method does not accept any parameter. ReturnsThe nextBigDecimal() method returns the BigDecimal scanned from the input. ExceptionsIllegalStateException- This method throws exception if the innvocation is done after the scanner has been closed. InputMismatchException- It will thrown exception if the next token does not match the Decimal regular expression or is out of range Compatibility VersionJava 1.5 and above Example 1Output: Enter the two decimal inputs- 123456789 987654321 Result is: 1111111110 Example 2Output: Exception in thread "main" java.util.InputMismatchException at java.base/java.util.Scanner.throwFor(Scanner.java:939) at java.base/java.util.Scanner.next(Scanner.java:1594) at java.base/java.util.Scanner.nextBigDecimal(Scanner.java:2742) at myPackage.ScannerNextBigDecimalExample2.main(ScannerNextBigDecimalExample2.java:7) Example 3Output: Not Found :Google.com Found :111 Not Found :+ Found :11111 Not Found := Found :11222.0 Not Found :true Next TopicJava-scanner-nextbiginteger-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