Reverse String Program in Java – Java Interview Question

This is common interview question, How to reverse String in Java without inbuilt method.

You have inbuilt method to reverse String in Java library, StringBuffer and StringBuilder class with reverse() method which can be used to reverse String in Java.


In this Java tutorial, you will see How to reverse String using StringBuffer, StringBuilder and How to reverse String without Inbuilt Method. Let’s see complete Java program for this beautiful Java programming exercise.


Reverse String Program with StringBuffer or StringBuilder

Output :

original String : EasyBix , reversed String xiBysaE
original String : SeleniumTutorial , reversed String lairotuTmuineleS


Reverse String Program with Recursion

Output : 

original String : EasyBix Selenium Tutorial , reversed String lairotuT muineleS xiBysaE


You can see in the First example, We have used inbuilt reverse() method of StringBuffer Class and StringBuilder class to reverse the String, and in the second example, We reversed the string using custom logic.
That’s all about, How to reverse String in Java.


0 Comment

Leave a Reply