logo

Java String Buffer Reverse() Method


Show

Description

This method undoes the worth of the StringBuffer object that appealed to the technique. Let n be the distance end to end of the old character series, the one hold in the string bumper just prior to the execution of the invalidate method. Then, the personality at index k in the new character chain is equal to the value at index n-k-1 in the old character sequence.

Syntax

Here is the syntax for this method:

public StringBuffer reverse()

Parameters

Here is the detail of parameters:

  • NA

Return Value

  • This method returns the StringBuffer object with the reversed sequence.

Example

public class Test {

   public static void main(String args[]) {
      StringBuffer buffer = new StringBuffer("Intelli Nuts");
      buffer.reverse();
      System.out.println(buffer);
   }  
}

This will produce the following result:

Output

stuN illetnI

Here at Intellinuts, we have created a complete Java tutorial for Beginners to get started in Java.