Tuesday 15, Apr 2025
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

01.package com.javatutorialcorner.javastring;
02. 
03.public class StringReverse {
04. 
05.    public static void main(String[] args) {
06.        String inputString = "Madam";
07.        String reversedString = new StringBuffer(inputString).reverse()
08.                .toString();
09.        System.out.println("Input String : " + inputString);
10.        System.out.println("Reversed String : " + reversedString);
11. 
12.    }
13. 
14.}

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

Related Posts:

  • How to convert a String to Lower caseFollowing example shows how to convert a string to lower case. Sample Programpackage com.javatutorialcorner.javastring;public class ToLowerCase { public static void main(String[] args) { String input = "Java tutoria… Read More
  • How to Split the String in JavaFollowing Example shows how to split the string using str.split(String pattern) method in Java. Sample Programpackage com.javatutorialcorner.javastring;public class SplitString { public static void main(String[] args) { … Read More
  • Remove the particular character from string Following example shows, how to remove particular character from string. Sample Program package com.javatutorialcorner.javastring; public class RemoveCharacter { public static void main(String[] args) { String … Read More
  • How to find last occurrence of substring inside stringFollowing example we are going to see about “how to find the last occurrence position of substring inside string using  lastIndexOf(String str) method in Java. Sample Programpackage com.javatutorialcorner.javastring;publ… Read More
  • How to reverse the String using StringBufferFollowing example shows how to reverse the String using StringBuffer. Sample Programpackage com.javatutorialcorner.javastring;public class StringReverse { public static void main(String[] args) { String inputString … Read More
  • 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