Google+

151. Using 'reverse( )' method with StringBuffer







reverse( )  method when used with StringBuffer reverses the characters in StringBuffer's object.

Example:

StringBuffer object1 = new StringBuffer("a12345z");
object1.reverse( ); -> This will reverse the string "a12345z" to "z54321a"

Lets implement this on Eclipse IDE:

1. Create 'reverseDemo' class under any project as shown below:



2. Save and Run the 'reverseDemo' class file
3. Observe that the output is displayed in the console as shown below:



Download this project:

Click here to download this project containing the class file used in this post (You can download this project and import into Eclipse IDE on your machine)




Please comment below to feedback or ask questions.

Using 'delete( )' method with StringBuffer will be explained in the next post.



No comments:

Blog Index