StringBuffer reverse() Method in Java with Examples Last Updated : 04 Aug, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The Java.lang.StringBuffer.reverse() is an inbuilt method that is used to reverse the characters in the StringBuffer. The method causes this character sequence to be replaced by the reverse of the sequence. Syntax: public StringBuffer reverse() Parameters: NA Return Value: The method returns the StringBuffer after reversing the characters. Examples: Input: StringBuffer = GeeksforGeeks! Output = !skeegrofskeeG Input: StringBuffer = Hello World! Output = !dlroW olleH Below are programs that illustrate the java.lang.StringBuffer.reverse() method: Program 1: java // Java program to illustrate the // java.lang.StringBuffer.reverse() import java.lang.*; public class Test { public static void main(String args[]) { StringBuffer sbf = new StringBuffer("Geeksforgeeks!"); System.out.println("String buffer = " + sbf); // Here it reverses the string buffer sbf.reverse(); System.out.println("String buffer after reversing = " + sbf); } } Output: String buffer = Geeksforgeeks! String buffer after reversing = !skeegrofskeeG Program 2: java // Java program to illustrate the // java.lang.StringBuffer.reverse() import java.lang.*; public class Test { public static void main(String args[]) { StringBuffer sbf = new StringBuffer("1 2 3 4 5 6 7 8 9 10"); System.out.println("String buffer = " + sbf); // Here it reverses the string buffer sbf.reverse(); System.out.println("String buffer after reversing = " + sbf); } } Output: 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 Comment More infoAdvertise with us Next Article StringBuilder reverse() in Java with Examples A ankita_chowrasia Follow Improve Article Tags : Java Java-Strings Java-lang package Java-Functions java-StringBuffer +1 More Practice Tags : JavaJava-Strings Similar Reads StringBuffer setCharAt() method in Java with Examples The setCharAt() method of StringBuffer class sets the character at the position index to character which is the value passed as parameter to method. This method returns a new sequence which is identical to old sequence only difference is a new character ch is present at position index in new sequenc 2 min read StringBuilder reverse() in Java with Examples The reverse() method of StringBuilder is used to reverse the characters in the StringBuilder. The method helps to this character sequence to be replaced by the reverse of the sequence. Syntax: public java.lang.AbstractStringBuilder reverse() Returns: This method returns StringBuilder object after re 1 min read StringBuffer delete() Method in Java with Examples The java.lang.StringBuffer.delete() is an inbuilt method in Java which is used to remove or delete the characters in a substring of this sequence. The substring starts at a specified index start_point and extends to the character at the index end_point. Syntax : public StringBuffer delete(int start_ 3 min read StringBuffer append() Method in Java with Examples Pre-requisite: StringBuffer class in Java The java.lang.StringBuffer.append() method is used to append the string representation of some argument to the sequence. There are 13 ways/forms in which the append() method can be used: StringBuffer append(boolean a) :The java.lang.StringBuffer.append(boole 13 min read StringBuffer toString() method in Java with Examples The toString() method of StringBuffer class is the inbuilt method used to returns a string representing the data contained by StringBuffer Object. A new String object is created and initialized to get the character sequence from this StringBuffer object and then String is returned by toString(). Sub 2 min read StringBuffer getChars() method in Java with Examples The getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) method of StringBuffer class copies the characters starting at the index:srcBegin to index:srcEnd-1 from actual sequence into an array of char passed as parameter to function. The characters are copied into the array of char dst[] star 3 min read Like