I have a question in regards to replacing certain characters. I have a string of x amount of characters, within which they contain all characters within the normal English alphabet.
String x = "exampleString"
My question is, because what i want to do is replace the characters that are within this string, I'm not able to user replace, as this replaces previously replaces strings, such as.
if(x.contains(e)){
x = x.replace("e","a")
}
That will replace every E character within the string above.
I was also trying to use:
x=x.replace("e","a").replace("a","b")
but that would also replace every a character, even the previously replaced. I though this would work, because strings are immutable in Java, however it doesn't.
I also considered counter to see when the string has been replaced and omit the replaced strings, however I'm not able to implement this.
Can anyone suggest solution?
Regards ProgrammingNewbie.