Recursive String Length Method
What should replace /* missing line */ to correctly calculate the length of a string recursively?
public static int stringLength(String s) {
if(s.equals("")) {
return 0;
}
/* missing line */
}
A
return 1 * stringLength(s.substring(1));
B
return 1 - stringLength(s.substring(1));
C
return 1 + stringLength(s.substring(1));
D
return stringLength(s.substring(1));
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE