replace duplicate characters in a string in java