The Java.lang.StringBuffer.reverse() is an inbuilt method which is used to reverse the characters in the StringBuffer. The method causes this character sequence to be replaced by the reverse of the sequence.
public StringBuffer reverse()
Parameters : The method does not take any parameter .
Return Value : The method returns the StringBuffer after reversing the characters.
Input: StringBuffer = GeeksforGeeks Output = !skeegrofskeeG Input: StringBuffer = Hello World Output = !dlroW olleH
Below programs illustrate the java.lang.StringBuffer.reverse() method:
String buffer = Geeksforgeeks! String buffer after reversing = !skeegrofskeeG
String buffer = 1 2 3 4 5 6 7 8 9 10 String buffer after reversing = 01 9 8 7 6 5 4 3 2 1
- StringBuffer replace() Method in Java with Examples
- StringBuffer append() Method in Java with Examples
- String toString() Method in java with Examples
- equals() on String and StringBuffer objects in Java
- Remove Leading Zeros From String in Java
- Counting number of lines, words, characters and paragraphs in a text file using Java
- Frequently asked questions for Java Developer Position from a fresher
- Reverse a string in Java
- Java.lang.Character Class in Java
- Java.io.BufferedReader Class in Java
- Exceptions in Java
- Map Interface in Java
- Ways to read input from console in Java
- How to Initialize and Compare Strings in Java?
- StringBuffer class in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.