Java StringBuilder reverse() Method Example

Java StringBuilder reverse() method causes this character sequence to be replaced by the reverse of the sequence.

Java StringBuilder reverse() Method Example

Example to reverse the given String "javaguides" using reverse() method.
public class ReverseExample {
    public static void main(String[] args) {
        StringBuilder builder = new StringBuilder("javaguides");
        StringBuilder reverse = builder.reverse();
        System.out.println("Reversed string :" + reverse);
    }
}
Output:
Reversed string :sediugavaj

Reference

Comments