StringBuffer reverse () : This method reverse the character sequence contained in the string buffer. In other words, the first character becomes the last, the second character becomes the second last and so on. For example, The Word “welcome” after reverse.
S1. reverse () will return emoclew.
Here is the Java Example for StringBuffer reverse():
public class StringBufferReverse
{
static void ReverseString()
{
String a ="Dinesh Thakur";
System.out.println("\nOriginal String : " + a);
StringBuffer b = new StringBuffer(a).reverse();
System.out.println("Reverse character string : "+b);
}
public static void main(String[] args)
{
ReverseString();
}
}