Hi I am trying understand the below recursion method but it seems too confusing. I know that the reversePrint method calls it self but my problem is, the first time it runs it should print bcdef + a = bcdef. Here is where I get confused, the next time it runs b becomes the charAt(0)... so where is a?? Do they get stored temporally in somewhere? Can someone please help me understanding it. Many thanks
public static void main(String[] args) {
// TODO code application logic here
System.out.println(reversePrint("abcdef"));
}
public static String reversePrint(String s) {
if (s.length() <= 1) {
return s;
}
return reversePrint(s.substring(1)) + s.charAt(0);
}