Reputation: 211
I'm trying to parse some extracted data. So, I can't find how do I to replace a detected String in Java?
I've tried this, but it doesn't work for me :
texte.replace("gras", "bold");
Any help please ?
Upvotes: 0
Views: 95
Reputation:
Strings are immutable, calling a method on a string will never change it.
texte = texte.replace("gras", "bold");
should do the trick
Upvotes: 0
Reputation: 37833
Strings are immutable. You need to assign the returned string to a string variable. E.g.
texte = texte.replace("gras", "bold");
or
String replaced = texte.replace("gras", "bold");
Upvotes: 4