Guest User

Untitled

a guest
Jan 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. public class ReverseRecursion {
  2. public static String reverseRecursively(String str) {
  3. if (str.length() < 2) {
  4. return str;
  5. } return reverseRecursively(str.substring(1)) + str.charAt(0);
  6. }
  7.  
  8. public static void main(String args[]) {
  9. String str = "Ammar Al-Nasseri";
  10. System.out.println("Original String: " + str);
  11. System.out.println("Reversed String: " + reverseRecursively(str));
  12. } // End Main
  13. } // End Class
Add Comment
Please, Sign In to add comment