Created
June 26, 2010 20:56
-
-
Save zachelko/454329 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 static String reverse(String str) | |
{ | |
int startIndex = 0; | |
int stopIndex = str.length() - 1; | |
char[] chArray = str.toCharArray(); | |
while (startIndex < stopIndex) | |
{ | |
char temp = chArray[stopIndex]; | |
chArray[stopIndex] = chArray[startIndex]; | |
chArray[startIndex] = temp; | |
++startIndex; | |
--stopIndex; | |
} | |
return new String(chArray); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment