07. Reverse String Using Recursive Method - prabhatrocks07/Core-Java-Programming GitHub Wiki

public class StringRecursiveReversal {

public static void main(String[] args) {
	System.out.println("-- Enter the String: --");
	Scanner sc = new Scanner(System.in);
	String str = sc.nextLine();
	sc.close();
	System.out.println("-- Reverse String is: --");
	
	System.out.println(reverseString(str));
	
}

private static String reverseString(String str) {
	String reverse = "";
	if(str != null && str.length() == 1) {
		return str;
	} else { 
		
		reverse += str.charAt(str.length() -1) + reverseString(str.substring(0, str.length() -1));
		return reverse;
	}
}

}