how to use replacement function in java