0
import java.text.DecimalFormat;
static DecimalFormat df4 = new DecimalFormat("#.0000");
Double a = 3591000;
Double d = a/10000000;
String str = df4.format(d);
這裏我期望0.3591,但df4.format在小數點前刪除0。印刷0.3591DecimalFormat格式在小數點前刪除前導0
如何獲得0.3591 – sks
因此,下一個理性的事情是閱讀文檔以瞭解您的錯誤並修復它。 https://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.html –