[Solved] Parsing an array of integers into a single int with Java [closed]


First of all, change 10**i to Math.pow(10,i).

Then name your char[] array. Let’s call it c.

Then, change c[i] to c[i]-'0', assuming c[i] is a digit.

private int parseInt(char[] c)
{
    int parsed = 0;
    for (i=0 ; i < c.length; i++)
        parsed += Math.pow(10,i) * (c[i]-'0');
    return parsed;
}

3

solved Parsing an array of integers into a single int with Java [closed]