簡體   English   中英

Java格式將double轉換為String

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM