Answers for "how to return the reverse of a string"

0

reverse a string

public static String reverse(String orig)
{
    char[] s = orig.toCharArray();
    int n = s.length;
    int halfLength = n / 2;
    for (int i=0; i<halfLength; i++)
    {
        char temp = s[i];
        s[i] = s[n-1-i];
        s[n-1-i] = temp;
    }
    return new String(s);
}
Posted by: Guest on July-23-2021

Code answers related to "how to return the reverse of a string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language