0 votes
1 view
in Java by (2.6k points)

I can use this:

String str = "TextX Xto modifyX";

str = str.replace('X','');//that does not work because there is no such character ''

Is there a way to remove all occurrences of character X from a String in Java?

I tried this and is not what I want: str.replace('X',' '); //replace with space

1 Answer

0 votes
by (46.1k points)

Try applying the overload that takes CharSequence arguments(eg, String) other than char:

str = str.replace("X", "");

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...