Basically, what I want to achieve is replacing each letter in a string with another letter or a combination of letters. First, I tried
String codedText = text.replace("a","b")
.replace("b","a")
.replace("cd", "c");
and so on, but the problem is the following. Using this one, it will replace in a infinite loop, also here is another problem. As you can see on the third replace part, I'm searching for a group of letters to replace with one, also sometime I'm using .replace("c", "cd")
, which means that there might be an output of 2 letters, in case of using .replace, it will try to replace the "d" letter aswell.
So, to make things a little bit clear, I need something that would basically split the text into array, each containing 1 letter, convert everything and after that make from array a text and output it. I hope I explained it pretty good, because it's really pretty hard to explain that as a newbie in java.