I'm trying to write a program that switches the "x" and "o" in a String, only using the replace method repeatedly.
At the end of the day, the program should turn 'xxxooo' into 'oooxxx'.
I understand why this isn't working, but I'm just completely out of ideas as to how to make it work. So here's what I have:
firstStep = console.nextLine();
secondStep = firstStep.replaceAll(o, x);
thirdStep = thirdStep.replace(x, o);
Is there a way to accomplish this replacement in one step?