Reverse String in Java - toarArray ()

public static String reverse(String str) 
{
    String rev="";
    char[] finalarray = str.toCharArray();
    for (int i = finalarray.length - 1; i >= 0; i--)
        rev+=finalarray[i];
    return rev;
}
//Sample Input- "Scaler Academy"
//Sample Output-"ymedacA relacS"
codelearner