convert String Array to Int Array - Android java.lang

Android examples for java.lang:array convert

Description

convert String Array to Int Array

Demo Code


public class Main{


    public static int[] convertStringArraytoIntArray(String[] sarray) {
        int intarray[] = null;

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

            try {
                for (int i = 0; i < sarray.length; i++) {
                    intarray[i] = Integer.parseInt(sarray[i]);
                }/*from  w ww.  j  a  v a  2  s .c  om*/
            } catch (NumberFormatException e) {
    
            }
        }

        return intarray;
    }

}

Related Tutorials