Why does String.replace not work? [duplicate]
Solution 1:
You did not assign it to test
. Strings are immutable.
test = test.replace("KP", "");
You need to assign it back to test
.
Solution 2:
Strings
are immutable so you need to assign your test
reference to the result of String.replace
:
test = test.replace("KP", "");