Convert String to Float Object in Java
Description
The following code shows how to convert String to Float Object.
Example
/* w w w.j av a2s.c om*/
public class Main {
public static void main(String[] args) {
Float fObj1 = new Float("10.64");
System.out.println(fObj1);
Float fObj2 = Float.valueOf("10.76");
System.out.println(fObj2);
float f = Float.parseFloat("7.39");
System.out.println(f);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »