I know of two ways of replacing all occurrences of substring in a string.
The regex way (assuming \"substring-to-be-replaced\" doesn\'t include regex specia
Instead of using strings, which are immutable, use char arrays or some other mutable type (such as StringBuffer or StringBuilder).
string
char
StringBuilder