Wild Plague Wild Plague - 2 months ago 7
Android Question

How to remove decimal point from a double value after converting it to astring

I want to remove a decimal point from a

double
value. I tried by converting it to string

double intify(double a)
{
String s=Double.toString(a);
String s2=s.replaceAll(".","");
a=Double.parseDouble(s2);

return a;

}


If I pass 123.4567 it should return 1234567.

Answer

replaceAll replaces a regex. You should use replace instead:

String s2 = s.replace(".","");