Here you can find the source of toFloat(String str)
public static float toFloat(String str)
//package com.java2s; //License from project: Mozilla Public License public class Main { public static float toFloat(String str) { return toFloat(str, 0.0f); }//w w w . j av a2 s . co m public static float toFloat(String str, float defaultValue) { if (str == null) { return defaultValue; } try { return Float.parseFloat(str); } catch (NumberFormatException nfe) { return defaultValue; } } }