How to distinguish the difference from finding the decimal number, but at the same time ignoring it, if it is a period?
For example, suppose Scanner
String s = "2015. 3.50 please";
When I use the function scanner.hasNextFloat()
, how to ignore Hi.?
I only scan 1 line. I need to determine if a word is a string, integer or float. My end result should look something like this:
This is a String: 2015.
This is a float: 3.50
This is a String: please
But in my conditions, when I use it scanner.hasNextFloat();
, it identifies 2015. as a float.
source
share