Created
April 30, 2012 06:55
-
-
Save thiagotn/2556106 to your computer and use it in GitHub Desktop.
InverteUrl
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 InverteUrl { | |
public static void main(String args[]) { | |
if (args.length == 0) { | |
throw new IllegalArgumentException("Cadê a url?"); | |
} | |
String url = args[0]; | |
int len = url.length(); | |
char[] tempCharArray = new char[len]; | |
char[] charArray = new char[len]; | |
// put original string in an | |
// array of chars | |
for (int i = 0; i < len; i++) { | |
tempCharArray[i] = url.charAt(i); | |
} | |
// reverse array of chars | |
for (int j = 0; j < len; j++) { | |
charArray[j] = tempCharArray[len - 1 - j]; | |
} | |
System.out.println(charArray); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment