Skip to content

Instantly share code, notes, and snippets.

@bitcpf
Created June 17, 2014 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitcpf/41a5195e675d9989bca0 to your computer and use it in GitHub Desktop.
Save bitcpf/41a5195e675d9989bca0 to your computer and use it in GitHub Desktop.
CC
/**
* Created by bitcpf on 6/17/14.
*/
public class reverseString {
public static char[] reverse(String s){
char[] s_char = s.toCharArray();
char inter;
int s_l = s.length()-1;
for(int i=0;i<s_l/2;i++){
inter=s_char[i];
s_char[i]=s_char[s_l-i];
s_char[s_l-i] = inter;
}
return s_char;
}
public static void main(String[] args){
String test = "12345";
System.out.println(test);
System.out.println(reverse(test));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment