Why does String.replace not work?
String is immutable in java so you have to do
test =test.replace("KP", "");
Strings
are immutable so you need to assign your test
reference to the result of String.replace
:
test = test.replace("KP", "");
You did not assign it to test
. Strings are immutable.
test = test.replace("KP", "");
You need to assign it back to test
.