/*
Java StringBuffer Reverse Example
This example shows how to reverse the content of the StringBuffer using
reverse method of Java StringBuffer class.
*/
public class JavaStringBufferReverseExample {
public static void main(String[] args) {
//create StringBuffer object
StringBuffer sb = new StringBuffer("Java StringBuffer Reverse Example");
System.out.println("Original StringBuffer Content : " + sb);
//To reverse the content of the StringBuffer use reverse method
sb.reverse();
System.out.println("Reversed StringBuffer Content : " + sb);
}
}
/*
Output Would be
Original StringBuffer Content : Java StringBuffer Reverse Example
Reversed StringBuffer Content : elpmaxE esreveR reffuBgnirtS avaJ
*/
Bookmark/Search this post with:
Question!!!!!!
I think it would be a foolish question to ask but still i am asking that the "Reverse" function of string buffer reverses the index location of characters.But what if i want the string to be in following form..
"Example Reverse StringBuffer Java" for input string "Java StringBuffer Reverse Example"....
Post new comment