Java Float Number Create toFloat(String str)

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

Description

to Float

License

Mozilla Public License

Declaration

public static float toFloat(String str) 

Method Source Code

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

Related

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