how to replace a chracter in a string java code example
Example 1: replace character in string java
String str = "..............................";
int index = 5;
char ch = '|';
StringBuilder string = new StringBuilder(str);
string.setCharAt(index, ch);
System.out.println(string);
Example 2: java replaceall single character
.replaceAll("(?<!\\S)[^ ](?!\\S)", " ").trim()