You did not assign it to test
. Strings are immutable.
test = test.replace("KP", "");
You need to assign it back to test
.
More Related Contents:
- Replace a character specific number of times in String Java
- String replace method is not replacing characters
- Replace a character at a specific index in a string?
- Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces
- Difference between String replace() and replaceAll()
- Java String replace not working [duplicate]
- Java Replacing multiple different substring in a string at once (or in the most efficient way)
- Strip Leading and Trailing Spaces From Java String
- How can non-ASCII characters be removed from a string?
- How to replace case-insensitive literal substrings in Java
- Replace the last part of a string
- String replace a Backslash
- Java String.replace/replaceAll not working
- How to replace first occurrence of string in Java
- String.replaceAll is considerably slower than doing the job yourself
- Remove all occurrences of \ from string
- Replace Last Occurrence of a character in a string [duplicate]
- Hints for java.lang.String.replace problem? [duplicate]
- How System.out.println(s1==s3.intern()); //return true? [closed]
- How do I convert a String to an int in Java?
- How to split a String by space
- When to use StringBuilder in Java [duplicate]
- Java Byte Array to String to Byte Array
- In Java, how do I parse XML as a String instead of a file?
- How to convert a color integer to a hex String in Android?
- Reverse each individual word of “Hello World” string with Java
- Consistency of hashCode() on a Java string
- StringUtils.isBlank() vs String.isEmpty()
- Strings written to file do not preserve line breaks
- Convert a String of Hex into ASCII in Java