Created
June 17, 2014 15:34
-
-
Save bitcpf/41a5195e675d9989bca0 to your computer and use it in GitHub Desktop.
CC
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
/** | |
* 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