If you read the API for String you would notice that the replace methods return a new String with the replacement carried out.
So all you need to do is assign the replaced version back to input.