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
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.