You can convert the string to a StringBuilder, use the setCharAt method to replace the character at the desired index, and then convert it back to a string.