I\'m trying to replace a character at a specific index in a string.
What I\'m doing is:
String myName = \"domanokz\";
myName.charAt(4) = \'x\';
You can overwrite a string, as follows:
String myName = "halftime";
myName = myName.substring(0,4)+'x'+myName.substring(5);
Note that the string myName
occurs on both lines, and on both sides of the second line.
Therefore, even though strings may technically be immutable, in practice, you can treat them as editable by overwriting them.