Just as the title says im trying to get the sum of a string's characters values, but in a recursive way and without for loops
i tried to do this, but it says that a return type required?

private stringSum(String s, int i)
    {
        if (i==a.length)
            return 0;
        return ((int)s.charAt(i)+ stringSum (s, i+1);
    }

Recommended Answers

Haha. Glad you got it solved so quickly!

Jump to Post

All 2 Replies

wow haha sorry guys nevermind this i just noticed that i forgot to add the type "int" hehe

Haha. Glad you got it solved so quickly!