Converting String using Float.parseFloat

@belinda.tan

You can parse a numeric string with comma, dot, sign etc into an instance of java.lang.Number value using java.text.DecimalFormat#parse(String) appropriately.
See for example
http://www.herongyang.com/JDK/Number-String-java-util-DecimalFormat-Parse-to-Object.html

You can cast a variable of java.lang.Number into a variable of type float by calling floatValue() method of Number. See https://www.tutorialspoint.com/java/lang/number_floatvalue.htm

1 Like