Here you can find the source of toFloat(String str, float defaultValue)
Parameter | Description |
---|---|
value | a parameter |
defaultValue | a parameter |
public static final float toFloat(String str, float defaultValue)
//package com.java2s; //License from project: Apache License public class Main { /**// w w w . ja v a 2 s.com * Convert the string to int. * @param value * @param defaultValue * @return */ public static final float toFloat(String str, float defaultValue) { float value = defaultValue; try { value = Float.parseFloat(str); } catch (NumberFormatException e) { value = defaultValue; } return value; } }