We are moved to new domain
Click -> www.ehowtonow.com
Sunday, 3 May 2015

How to reverse the String using StringBuffer

Following example shows how to reverse the String using StringBuffer.

Sample Program

package com.javatutorialcorner.javastring;

public class StringReverse {

public static void main(String[] args) {
String inputString = "Madam";
String reversedString = new StringBuffer(inputString).reverse()
.toString();
System.out.println("Input String : " + inputString);
System.out.println("Reversed String : " + reversedString);

}

}


Output


The above code will produce the following output



Input String : Madam
Reversed String : madaM

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: How to reverse the String using StringBuffer Rating: 5 Reviewed By: eHowToNow