how to replace a character in a string in java without using replace method