xxxxxxxxxx
import java.util.*;
class remove
{
public static void main(String str[])
{
String str1="viaks";
StringBuilder b= new StringBuilder();
b.append(str1);
b.delete(0,1);
System.out.println(b.toString());
}
}
xxxxxxxxxx
public class Test {
private static int i = 0;
public static void main(String args[]) {
reverse("Hello");
}
public static String reverse(String str) {
int localI = i++;
if ((null == str) || (str.length() <= 1)) {
return str;
}
System.out.println("Step " + localI + ": " + str.substring(1) + " / " + str.charAt(0));
String reversed = reverse(str.substring(1)) + str.charAt(0);
System.out.println("Step " + localI + " returns: " + reversed);
return reversed;
}
}
xxxxxxxxxx
import java.util.*;
import javax.swing.*;
class recursion
{
static String recursive(String str)
{
return recursive(str);
}
public static void main(String str[])
{
String str1="vikas";
char ch[]=str1.toCharArray();
for(int i=ch.length-1;i>=0;i--)
{
String s2=String.valueOf(ch[i]);
System.out.print(s2);
}
}
}
xxxxxxxxxx
public static String reverse(String str)
{
if(str.length() == 0)
return "";
return str.charAt(str.length()-1) + reverse(str.substring(0,str.length()-1));
}