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

reverse() StringBuilder method in java

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

Syntax: public StringBuilder reverse().

Example:

StringBuilderReverseExample.java

/**
 * This program is used to show the use of reverse() method.
 * @author javawithease
 */
class TestStringBuilder{
	StringBuilder sb = 
                new StringBuilder("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 StringBuilderReverseExample {
	public static void main(String args[]){
		//creating TestStringBuilder object
		TestStringBuilder obj = new TestStringBuilder();
 
		//method call
		obj.reverseTest();
	}
}

Output:

moc.esaehtiwavaj.www

Download this example.
 
Next Topic: capacity() StringBuilder method in java.
Previous Topic: delete(int startIndex, int endIndex) StringBuilder method in java.

Related Topics:

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

 


Comments are closed.