Reverse String using StringBuffer in java



In this programming tutorial we will learn how to reverse String in java with example, diagram and program by using StringBuffer in java.





Example in java -
String: abcde
output: edcba


Must read:Fibonacci series in java.    

Full Program/Example >
/** Copyright (c), AnkitMittal www.JavaMadeSoEasy.com */
public class ReverseStringUsingStringBufferExample {
   public static void main(String...args){
          String originalString="abcde"; //String to be reversed
          StringBuffer sb=new StringBuffer(originalString);
         
          System.out.println("Original String: "+originalString);
          System.out.println("Reversed String: "+sb.reverse());     
   }
  
  
}
/*OUTPUT
Original String: abcde
Reversed String: edcba
*/

So in this programming tutorial we learned how to reverse String in java with example, diagram and program by using StringBuffer in java.

Previous program                                                                  Next program


Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.



RELATED LINKS>







eEdit
Must read for you :