216
How to reverse String in Java
There are many ways to reverse String in Java. We can reverse String using StringBuffer, StringBuilder, iteration etc. Let’s see the ways to reverse String in Java.
1) By StringBuilder / StringBuffer
File: StringFormatter.java
File: TestStringFormatter.java
Output:
nahk si eman ym lawsiaj oonos ma I
2) By Reverse Iteration
File: StringFormatter.java
File: TestStringFormatter.java
Output:
nahk si eman ym lawsiaj oonos ma I
Next TopicJava String FAQs