【问题标题】:show 2 decimal place of a double using JOptionPane in Java [duplicate]在Java中使用JOptionPane显示双精度的2个小数位[重复]
【发布时间】:2017-10-21 07:05:26
【问题描述】:

【问题讨论】:

  • 1987 年出生!= 26 岁

标签: java


【解决方案1】:

使用 DecimalFormatter 格式化要显示的小数点数。

DecimalFormat decimalFormat = new DecimalFormat("#.00");
decimalFormat.format(bmi);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-02
    相关资源
    最近更新 更多