Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- public static String reverseRec(String s) {
- if (s.isEmpty()) return "";
- return s.charAt(s.length() - 1) + reverseRec(s.substring(0, s.length() - 1));
- }
- public static void main(String[] args) {
- System.out.println(reverseRec("mahmoud"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment