Possible Duplicate:
java : convert float to String and String to float
I’m extracting some numbers from a string, these are being stored as another string. Is there a way to convert these strings into a float?
i tried float f = “string”; but this didnt work.
Thanks
Try Float.parseFloat but it does throw a RuntimeException if it fails so this is one time I would recommend catching it.
If you want more precision then look at Double.parseDouble() or even the BigDecimal string constructor