Convert a String to a float type Number with Float.parseFloat in Java
Description
The following code shows how to convert a String to a float type Number with Float.parseFloat.
Example
//from w ww. java 2 s.co m
public class Main {
public static void main(String[] argv) throws Exception {
float f = Float.parseFloat("123.4");
System.out.println(f);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »