Java Float Number Create toFloat(String str, float defaultValue)

Here you can find the source of toFloat(String str, float defaultValue)

Description

Convert the string to int.

License

Apache License

Parameter

Parameter Description
value a parameter
defaultValue a parameter

Declaration

public static final float toFloat(String str, float defaultValue) 

Method Source Code

//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;
    }
}

Related

  1. toFloat(String s)
  2. toFloat(String str)
  3. toFloat(String str)
  4. toFloat(String str)
  5. toFloat(String str, float defaultValue)
  6. toFloat(String string)
  7. toFloat(String text)
  8. toFloat(String text)
  9. toFloat(String value)