Skip to content

Instantly share code, notes, and snippets.

@epson121
Created February 1, 2014 20:08
Show Gist options
  • Select an option

  • Save epson121/8758013 to your computer and use it in GitHub Desktop.

Select an option

Save epson121/8758013 to your computer and use it in GitHub Desktop.
class ReverseString {
public static void main(String[] args) {
int last = args[0].length()-1;
char[] chars = args[0].toCharArray();
for (int i = 0; i < args[0].length()/2; i++) {
char temp = chars[i];
chars[i] = chars[last];
chars[last--] = temp;
}
System.out.println(new String(chars));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment