Java StringBuffer reverse String value

Introduction

We can reverse the characters within a StringBuffer object using reverse() method:

StringBuffer reverse() 
// Using reverse() to reverse a StringBuffer.
public class Main {
  public static void main(String args[]) {
    StringBuffer s = new StringBuffer("abcdef");

    System.out.println(s);/*www .  j a  v  a2s .  c om*/
    s.reverse();
    System.out.println(s);
  }
}



PreviousNext

Related