String are immutable in Java. You can't change them.

You need to create a new string with the character replaced.

String myName = "domanokz";
String newName = myName.substring(0,4)+'x'+myName.substring(5);

or you can use a StringBuilder:

StringBuilder myName = new StringBuilder("domanokz");
myName.setCharAt(4, 'x');

System.out.println(myName);

http://stackoverflow.com/questions/6952363/java-replace-a-character-at-a-specific-index-in-a-string

相关文章:

  • 2022-01-02
  • 2022-02-07
  • 2022-01-21
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-01
  • 2021-05-15
  • 2022-12-23
  • 2021-11-02
  • 2021-08-23
  • 2021-07-13
相关资源
相似解决方案