java tutorial - Java StringBuffer reverse() method - java programming - learn java - java basics - java for beginners



Java  stringbuffer reverse

Learn Java - Java tutorial - Java stringbuffer reverse - Java examples - Java programs

Description

The reverse () method — changes the value of the StringBuffer object that called the method.

  • Let n be the length of the old sequence of characters contained simply in the string buffer (StringBuffer) before the reverse () method is executed.
  • Then, the symbol with the index k in the new sequence of symbols is equal to the symbol with the index nk-1 in the old sequence of symbols. In other words, the method returns a string in the reverse order.

Syntax

Syntax method:

public StringBuffer reverse()
click below button to copy the code. By - java tutorial - team

Options

Detailed information about the parameters:

  • No.

Return value

  • In Java, reverse () returns a StringBuffer with the reverse sequence.In Java, reverse () returns a StringBuffer with the reverse sequence.

Sample Code

public class Test {

public static void main (String args []) {
StringBuffer buffer = new StringBuffer ("wikitechy tutorials");
buffer.reverse ();
System.out.println (buffer);
}
}
click below button to copy the code. By - java tutorial - team

Output

slairotut yhcetikiw

Related Searches to Java StringBuffer reverse() method