Java Example: Reversing a string using StringBuilder Class

This entry is part 54 of 54 in the series Learn Java

Java provides us with a StringBuilder class that allows us to reverse a string with only one statement.

Consider the following example.

package reverse;

public class Reverse {

    private static String reverseString(String str) {

        return new StringBuilder(str).reverse().toString();


    public static void main(String[] args) {

        String input = "Hotel California";




Series Navigation<< Java: Final method

Leave a comment

Leave a Reply