[英]Java formatted converting double to String
我有这个:
double indPay;
double indPayment[];
DecimalFormat myFormat = new DecimalFormat("##.00");
但是当我这样做时:
indPay = myFormat.format(indPayment[q]);
我得到: Type mismatch. Cannot convert from String to double.
Type mismatch. Cannot convert from String to double.
为什么是这样?
编辑:有没有通过此字符串过程格式化双精度格式的任何方法?
indPay是双精度型,您正在尝试在其中存储一个字符串; 试试String str = myFormat.format(indPayment[q]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.