Java StringBuffer reverse() Example

Java StringBuffer reverse() method - Causes this character sequence to be replaced by the reverse of the sequence.

Java StringBuffer reverse() Example

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

Reference


Comments