Databases

Kodejava

Tag Archives: Float

When creating a program we will use a lot of string to represent our data. The data might not just information about our customer name, email or address, but will also contains numeric data represented as string. So how do we know if this string contains a valid number?

Java provides some wrappers to the primitive data types that can be used to do the checking.

In the example code we use Integer.parseInt(), Float.parseFloat(), Double.parseDouble() methods to check the validity of our numeric data. If the string is not a valid number NumberFormatException will be thrown.

The result of our example:

Age : 15
Height: 160.5
Weight: 55.9

Search for:

Subscribe to Kode Java via Email

Enter your email to subscribe and receive notifications of new posts by email.