Created
August 13, 2019 06:13
-
-
Save gauravkukade/fb03909eb1a6644e00cc65c606cebf84 to your computer and use it in GitHub Desktop.
A Java program to reverse a string. We are using 'reverse()' method of the StringBuilder class. This method rverse the character sequence represented by the string. The program is embedded at https://coderolls.com/reverse-a-string-in-java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Java program to reverse a string. | |
* | |
* We are using 'reverse()' method of the StringBuilder class. This method rverse the | |
* character sequence represented by the string. | |
* | |
* @author Gaurav Kukade at coderolls.com | |
*/ | |
public class ReverseStringUsingReverseMethodOfStringBuilder { | |
public static void main(String[] args) { | |
String blogName = "coderolls.com"; | |
StringBuilder stringBuilder = new StringBuilder(blogName); | |
stringBuilder = stringBuilder.reverse(); | |
System.out.print("The reversed string of the '"+blogName+"' is: "); | |
System.out.println(stringBuilder); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment