Skip to content

Instantly share code, notes, and snippets.

@eddimas
Created May 9, 2016 06:20
Show Gist options
  • Save eddimas/7f7edba2168db15b7cea4d31434598b5 to your computer and use it in GitHub Desktop.
Save eddimas/7f7edba2168db15b7cea4d31434598b5 to your computer and use it in GitHub Desktop.
This is a common palindrome example in java.
public class reverseString{
public static void main (String[] args){
String str = new String(args[0]);
int x = str.length();
char[] strArray = new char[x];
for(int i = 0; i < str.length(); i++){
strArray[i] = str.charAt(--x);
}
String finalString = new String(strArray);
System.out.println(strArray);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment