How to reverse the content of the StringBuffer using reverse method of Java StringBuffer class. - Java Language Basics

Java examples for Language Basics:StringBuffer

Description

How to reverse the content of the StringBuffer using reverse method of Java StringBuffer class.

Demo Code


public class Main {
  public static void main(String[] args) {
    StringBuffer sb = new StringBuffer("Java StringBuffer Reverse Example");
    System.out.println("Original StringBuffer Content : " + sb);
   // w  ww  . j  av  a 2  s. co  m
    //To reverse the content of the StringBuffer use reverse method
    sb.reverse();
    System.out.println("Reversed StringBuffer Content : " + sb);
  }
}

Result


Related Tutorials