Reverse a string : String « Data Type « Java






Reverse a string

    
public class Main {
  public static void main(String[] args) {
    String words = "Morning";

    String reverse = new StringBuffer(words).reverse().toString();

    System.out.println("Normal : " + words);
    System.out.println("Reverse: " + reverse);
  }
}

   
    
    
    
  








Related examples in the same category

1.Get String hash code
2.To extract Ascii codes from a String
3.LengthOf - show length of things
4.Show string escapesShow string escapes
5.Convert string to char array
6.See if Strings are shared in Java
7.Find text between two strings
8.If a string is empty or not
9.Count word occurrences in a string
10.Check for an empty string
11.Remove leading and trailing space from String
12.Put quotes around the given String if necessary.
13.Starts With Ignore Case
14.Repeat String
15.implements CharSequence