Java Scanner hasNextBigDecimal() Method

The hasNextBigDecimal() is a method of Java Scanner class which is used to check if the next token in this scanner's input can be interpreted as a BigDecimal using the nextBigDecimal() method or not. It returns true if the scanner's input can be interpreted as a BigDecimal, otherwise returns false.

Syntax

Following is the declaration of hasNextBigDecimal() method:

Parameter

This method does not accept any parameter.

Returns

The hasNextBigDecimal() method returns true if and only if this scanner's next token is a valid BigDecimal.

Exceptions

IllegalStateException

Compatibility Version

Java 1.5 and above

Example 1

Output:

Result: false
String: JavaTpoint.com

Example 2

Output:

Result: true
String Value: 4564.00

Example 3

Output:

false
Hello
false
JavaTpoint!
true
13
false
+
true
13.0
false
=
true
26