convert String Array to Float Array - Android java.lang

Android examples for java.lang:array convert

Description

convert String Array to Float Array

Demo Code


public class Main{

    public static Float[] convertStringArraytoFloatArray(String[] sarray) {
        Float[] intarray = null;/*from   w ww . ja va 2 s  .  c  o  m*/

        if (sarray != null) {
            intarray = new Float[sarray.length];

            try {
                for (int i = 0; i < sarray.length; i++) {
                    intarray[i] = Float.parseFloat(sarray[i]);
                }
            } catch (NumberFormatException e) {

            }
        }

        return intarray;
    }

}

Related Tutorials