Labels

algorithms (22) Design Patterns (20) java (19) linux (14) Snippet (13) service mix (6) soa (4)

String reversal using recursion

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);
}
}
}

No comments:

Post a Comment

Search 24 Bytes