Skip to content

Instantly share code, notes, and snippets.

@zachelko
Created June 26, 2010 20:56
Show Gist options
  • Save zachelko/454329 to your computer and use it in GitHub Desktop.
Save zachelko/454329 to your computer and use it in GitHub Desktop.
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