public class RecursionExample {
    public static void main (String[] args) {
        System.out.println(ittReverseString("Hello World"));
        System.out.println(recReverseString("Hello World"));
    }
    
    static String ittReverseString(String str) {
        String reversed = "";
        for (int i = 0; i < str.length(); i++) {
            reversed = str.charAt(i) + reversed;
        }
        return reversed;
    }
    
    static String recReverseString(String str) {
        if (str.length() == 0) {
            return "";
        }else{
            return recReverseString(str.substring(1)) + str.charAt(0);
        }
    }
    
}	