Created
May 9, 2016 06:20
-
-
Save eddimas/7f7edba2168db15b7cea4d31434598b5 to your computer and use it in GitHub Desktop.
This is a common palindrome example 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
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