将字符串转换为双精度后的问题

Problems after converting string to double

我对 java 还很陌生,因此我不知道为什么这不起作用。你能告诉我为什么会出现这个错误吗?

我已经导入了java.text.NumberFormat

NumberFormat fmt1 = NumberFormat.getcurrencyInstance();
String r = "12579500";
double s = Double.parseDouble(r);
double t = fmt1.format(s);

编译时我得到:不兼容的类型:

string cannot be converted to double

fmt1.format(s)returns一个String(根据NumberFormat格式化String)。
doubleString 是无法比较的类型。

final String formatted = fmt1.format(s);

顺便说一句,您在 NumberFormat.getCurrencyInstance() 中打错了字。