• August 28, 2014
  • Core Java
  • Comments Off on reverse() StringBuffer method in java

reverse() StringBuffer method in java

reverse(): replace the string buffer’s character sequence by reverse character sequence.

Syntax: public synchronized  StringBuffer reverse().

Example:

StringBufferReverseExample.java

/**
 * This program is used to show the use of reverse() method.
 * @author javawithease
 */
class TestStringBuffer{
	StringBuffer sb = new StringBuffer("www.javawithease.com");
 
	/**
	 * This method is used to show the use of reverse() method.
	 * @author javawithease
	 */
	public void reverseTest(){
		//replace the string buffer’s character 
                //sequence by reverse character sequence.
		System.out.println(sb.reverse());
	}
}
 
public class StringBufferReverseExample {
	public static void main(String args[]){
		//creating TestStringBuffer object
		TestStringBuffer obj = new TestStringBuffer();
 
		//method call
		obj.reverseTest();
	}
}

Output:

moc.esaehtiwavaj.www

Download this example.

Related Topics:

StringBuffer in java. append(String str) StringBuffer method in java. insert(int offset, String str) StringBuffer method in java.
replace(int startIndex, int endIndex, String str) StringBuffer method in java. delete(int startIndex, int endIndex) StringBuffer method in java. reverse() StringBuffer method in java.
capacity() StringBuffer method in java. ensureCapacity(int minCapacity) StringBuffer method in java. StringTokenizer in java.

 


Comments are closed.