parse string to Float - Android java.lang

Android examples for java.lang:Float

Description

parse string to Float

Demo Code

import java.util.List;
import java.util.Map;

public class Main{

    public static float parseFloat(String str, float defaultValue) {
        try {//from ww w  .  j a va 2s.c o  m
            return Float.parseFloat(str);
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }

}

Related Tutorials