Reverse of a String using recursion in Java

Reverse of a String with out using Library functions is a general interview question.For any such questions, check whether the problem can be solved with Algorithmic Design techniques. Most of the problems that contain loops can be re-written as recursive programs, can be a solution for such interview questions. Recursion and Divide and Conquer strategy of Algorithmic Design Techniques can be used to solve problems of such kind.

Algorithm for Reverse of a String using Recursion

Base Case: if String length is less than 2, i.e., if string is devised to one character then return the character.
Recursive: Extract first character, call method to itself on the sub problem i.e., with sub string leaving first character. Append every first character of the sub problem to the end of the result.

Here is the implementation for Reverse of a string using recursion in java


Leave a Comment