Java – Convert String into float

String can be converted into float in java by parseFloat() method. Type casting is a method to change string to float.

Example of converting string to float

public class StringToFloatConvert {

    public static void main(String[] args) {

        String string_to_float="1234.89";

        float flt=Float.parseFloat(string_to_float);

        System.out.println("Type cast string to float :"+flt);
    }
}

Output

Type cast string to float :1234.89

Tags:

Bookmark  

 

Leave a Reply

Security Code:

 

  Random Post