public class A {
public static void main(String[] args) {
String temp = "TESTING";
temp = getString(temp);
System.out.println(temp);
}
public static String getString(String asTemp) {
if (asTemp.length() == 0)
return asTemp;
else {
return getString(asTemp.substring(1, asTemp.length()))
+ asTemp.substring(0, 1);
}
}
}
Labels
String reversal using recursion
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment