Java Float Number Create toFloat(String property, float f)

Here you can find the source of toFloat(String property, float f)

Description

tries to parse the given String into a float value if this fails the default value is returned

License

Apache License

Parameter

Parameter Description
property a parameter
f a parameter

Declaration

public static float toFloat(String property, float f) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from  ww  w  . j a v a  2s  . c o  m*/
     * tries to parse the given String into a float value
     * if this fails the default value is returned
     * @param property
     * @param f
     * @return
     */
    public static float toFloat(String property, float f) {
        try {
            return Float.parseFloat(property);
        } catch (NumberFormatException ex) {
            return f;
        }
    }
}

Related

  1. toFloat(Object value)
  2. toFloat(short half)
  3. toFloat(short[] arr)
  4. toFloat(short[] src)
  5. toFloat(String parameter)
  6. toFloat(String s)
  7. toFloat(String s)
  8. toFloat(String s)
  9. toFloat(String str)