Sep 03

The Float class contains a number of (static) methods for converting to/from various formats. To convert to a float use static method Float.parseFloat().


String s = "123.456";
try
{
   float f = Float.parseFloat(s);
}
catch (NumberFormatException ex)
{
   // s is not a float
}

written by objects \\ tags: , ,


Leave a Reply

You must be logged in to post a comment.