Skip to content

Instantly share code, notes, and snippets.

@thiagotn
Created April 30, 2012 06:55
Show Gist options
  • Save thiagotn/2556106 to your computer and use it in GitHub Desktop.
Save thiagotn/2556106 to your computer and use it in GitHub Desktop.
InverteUrl
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