|
Java™ by example!
|
|
|
How do I replace characters in a String?
It does work! Most likely, you have forgotten one important property of a String object: it's immutable. Once it's created, a String can't change. replace takes two characters as arguments and replaces all occurrences of the first char into the second. Internally, it creates a new String object which the method uses to do its modifications. It returns this new string object. So: not
but:
Further Information
Author of answer: Joris Van den Bogaert
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|