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\';
I agree with Petar Ivanov but it is best if we implement in following way:
public String replace(String str, int index, char replace){
if(str==null){
return str;
}else if(index<0 || index>=str.length()){
return str;
}
char[] chars = str.toCharArray();
chars[index] = replace;
return String.valueOf(chars);
}