The problem is that x = x.replaceAll(".", "");
replaces every character with ""
and therefore you have an empty x
after the second replaceAll()
.
Note that the first argument of the replaceAll()
method is a regular expression.
Change it to:
x = x.replaceAll("\\.", "");