public static float asFloat(String str,float def){
  try {
    return Float.parseFloat(str);
  }
 catch (  NumberFormatException e) {
    return def;
  }
}

public static float asFloat ( String str , float def ) { try { return Float . parseFloat ( str ) ; } catch ( NumberFormatException e ) { return def ; } }
parse string to float , if string can ' t be parsed to float , then it will return given default value .
