I am a little bit confused at the moment. I tried that:
String test = "KP 175.105";
test.replace("KP", "");
System.out.println(test);
and got:
KP 175.105
However, I want:
175.105
What's wrong with my code?
I am a little bit confused at the moment. I tried that:
String test = "KP 175.105";
test.replace("KP", "");
System.out.println(test);
and got:
KP 175.105
However, I want:
175.105
What's wrong with my code?
String is immutable in java so you have to do
Strings
are immutable so you need to assign yourtest
reference to the result ofString.replace
:you did not assigned to test.Strings are
immutable
you need to assign to test again.