Mahmoud_Hawara

Untitled

Jan 7th, 2026
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.31 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Main {
  4.    
  5.     public static String reverseRec(String s) {
  6.         if (s.isEmpty()) return "";
  7.         return s.charAt(s.length() - 1) + reverseRec(s.substring(0, s.length() - 1));
  8.     }
  9.    
  10.     public static void main(String[] args) {
  11.         System.out.println(reverseRec("mahmoud"));
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment