Recursive String Method Output
What is printed when the following code is executed?
public class CustomReverse {
public static String customRev(String s) {
if(s.length() <= 1) return s;
return s.charAt(0) + customRev(s.substring(1)) + s.charAt(0);
}
public static void main(String[] args) {
System.out.println(customRev("ab"));
}
}
A
abba
B
baa
C
abab
D
aba
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE