Java Float Number Create toFloat(String str)

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

Description

to Float

License

Open Source License

Declaration

public static float toFloat(String str) 

Method Source Code

//package com.java2s;
/**//w ww. j  a  v  a  2 s.c  o  m
 * Copyright (c) Nulla Development Group, 2014-2015
 * ??????????Nulla???????????
 * Developed by Kanbe-Kotori.
 * ??????? Kanbe-Kotori??????
 * This project is open-source, and it is distributed under
 * the terms of GNU General Public License. You can modify
 * and distribute freely as long as you follow the license.
 * ???????????????????????GNU????????????
 * ????????????????????????????????????
 * http://www.gnu.org/licenses/gpl.html
 */

public class Main {
    public static float toFloat(String str) {
        if (isNumeric(str))
            return Float.valueOf(str);
        return 0;
    }

    public static boolean isNumeric(String str) {
        try {
            Float.valueOf(str);
        } catch (Exception e) {
            return false;
        }
        return true;
    }
}

Related

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