In this guide, we will see how to convert String to float in Java. We will use the parseFloat() method of Float class for this conversion.
public static float parseFloat(String str)
This method takes string argument and returns a float number represented by the argument str.
Program to Convert String to float
public class JavaExample{
public static void main(String args[]){
String str = "15.6515";
float floatNum = Float.parseFloat(str);
System.out.println("String to float: "+floatNum);
}
}
Output: