Reverse a String using Recursion

Objective: Given a String, write a recursive program to reverse it.

Example:

Original String: tutorial horizon
Reversed String: noziroh lairotut

Approach:

  • Take the first character out of the string, add it to the end of result of the remaining string.
  • Make a recursive call to remaining string.

Java Code:

Output:

Original String: tutorial horizon
Reversed String: noziroh lairotut

__________________________________________________
Top Companies Interview Questions..-

Google Microsoft Amazon Facebook more..

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.
__________________________________________________

You may also like...

%d bloggers like this: