Java replace method, replacing with empty character

java, string

Solution

If you just exchange single for double quotes, this will work because an empty string is a legal value, as opposed to an "empty character", and there's an overload `replace(CharSequence, CharSequence)`. Keep in mind that `CharSequence` is the supertype of `String`.

Problem

Suppose I have the following in `String` format: `2.2` And I want to replace the decimal point with an empty space, to make it look like this: `22` How do I do this? I thought `replace` would have done the trick, but when I try it like this: `string.replace('.', '');` I get an error with the `''` because it supposedly isn't a character. That makes sense, so how else can I accomplish what I want?

Original source

Related problems