CodesJava

Easy learning with example program codes

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 codesjava
 */
class TestStringBuffer{
	StringBuffer sb = new StringBuffer("www.codesjava.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.avajsedoc.www

Download this example.

 

Please follow and like us:
error
Posted in Java   








Copyright © 2019 CodesJava DMCA.com Protection Status