Skip to content

Instantly share code, notes, and snippets.

@reza-ryte-club
Created August 22, 2015 07:23
Show Gist options
  • Save reza-ryte-club/7b13be42ae3855736c39 to your computer and use it in GitHub Desktop.
Save reza-ryte-club/7b13be42ae3855736c39 to your computer and use it in GitHub Desktop.
Reverse A String
public class StringReverse {
public static String reverseString(String str){
StringBuilder dest = new StringBuilder(str.length());
for(int i = str.length()-1;i>=0;i--){
dest.append(str.charAt(i));
}
return dest.toString();
}
public static void main(String[] args) {
System.out.println("reverse string");
String word = "Hello world";
System.out.println(reverseString(word));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment