Java Scanner hasNextFloat() MethodThe hasNextFloat() 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 float value using the nextFloat() method. It returns true if the scanner's input can be interpreted as a float value, otherwise returns false. SyntaxFollowing is the declaration of hasNextFloat() method: ParameterThis method does not accept any parameter. ReturnsThe hasNextFloat() method returns true if and only if this scanner's next token is a valid float value. ExceptionsIllegalStateException Compatibility VersionJava 1.5 and above Example 1Output: Result: false Scan String: JavaTpoint.com! Example 2Output: Scan String: Hello false Scan String: World! true Scan String: 12 false Scan String: + true Scan String: 13.0 false Scan String: = true Scan String: 15.00 true Scan String: 2.123 Example 3Output: Please enter value: 454.787 Your entered value: true Next TopicJava-scanner-hasnextint-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