Campbell Ritchie wrote:Determining whether a String like "Campbell" "123" or "123.45" can represent a number or an integer looks like a job for regular expressions. Whether the String "1" represents writing with a number in, an integer 1, a floating-point 1.0 or the character '1' is for you to decide.
You will find more about the Java™ grammar for such "primitives" in this Java Language Specification section.