public class ReverseString {
    public static void main(String[] args){
        System.out.println(reverse("Hello"));
        System.out.println(reverse("nathan"));
        System.out.println(reverse("racecar"));
        System.out.println(reverse("taco"));
        System.out.println(reverse("ABBA"));
        System.out.println(reverse(""));
        System.out.println(reverse("a"));
    }

    public static String reverse(String str){
        if (str.isEmpty()) {
            return "";
        } else if (str.length() == 1) {
            return str;
        }

        String backwards = reverse(str.substring(1)) + str.charAt(0);
        return backwards;
    }
}
