

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to reverse a string using recursion
Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function. You can reverse a string using the recursive function as shown in the following program.
Example
public class StringReverse { public String reverseString(String str){ if(str.isEmpty()){ return str; } else { return reverseString(str.substring(1))+str.charAt(0); } } public static void main(String[] args) { StringReverse obj = new StringReverse(); String result = obj.reverseString("Tutorialspoint"); System.out.println(result); } }
Output
tniopslairotuT
- Related Questions & Answers
- Python Program to Reverse a String Using Recursion
- Java Program to Reverse a Sentence Using Recursion
- Python Program to Reverse a String without using Recursion
- C++ program to Reverse a Sentence Using Recursion
- Python Program to Reverse a Stack using Recursion
- Java Program to Reverse a String Using Stacks
- Java Program to Reverse a String
- Write program to reverse a String without using reverse() method in Java?
- Java Program to Find G.C.D Using Recursion
- C# program to reverse a string
- C++ program for length of a string using recursion
- Python Program to Display the Nodes of a Linked List in Reverse using Recursion
- Factorial program in Java using recursion.
- Write a java program to reverse each word in string?
- How to reverse a string using lambda expression in Java?
Advertisements