import java.io.*; import java.lang.*; public class StringToFloat{ public static void main (String[] args) throws IOException{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the numeric type string value:"); String str = reader.readLine(); try{ float f = Float.valueOf(str.trim()).floatValue(); System.out.println("Float value is: = " + f); } catch (Exception e){ System.out.println("Exception: " + e.getMessage()); } } }