1public static String reverse(String str) {
2 if ((null == str) || (str.length() <= 1)) {
3 return str;
4 }
5 return reverse(str.substring(1)) + str.charAt(0);
6}
1public class Test {
2
3 private static int i = 0;
4
5 public static void main(String args[]) {
6 reverse("Hello");
7 }
8
9 public static String reverse(String str) {
10 int localI = i++;
11 if ((null == str) || (str.length() <= 1)) {
12 return str;
13 }
14 System.out.println("Step " + localI + ": " + str.substring(1) + " / " + str.charAt(0));
15 String reversed = reverse(str.substring(1)) + str.charAt(0);
16
17 System.out.println("Step " + localI + " returns: " + reversed);
18 return reversed;
19 }
20}
1import java.util.*;
2import javax.swing.*;
3class recursion
4{
5
6static String recursive(String str)
7{
8return recursive(str);
9
10}
11public static void main(String str[])
12{
13String str1="vikas";
14char ch[]=str1.toCharArray();
15for(int i=ch.length-1;i>=0;i--)
16{
17String s2=String.valueOf(ch[i]);
18System.out.print(s2);
19}
20}
21}
1import java.util.*;
2class remove
3{
4public static void main(String str[])
5{
6String str1="viaks";
7StringBuilder b= new StringBuilder();
8b.append(str1);
9b.delete(0,1);
10System.out.println(b.toString());
11}
12}