replace a char with a string in 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()