how to print a Double without commas

后端 未结 10 717
萌比男神i
萌比男神i 2020-12-11 15:37

When using toString(), Double adds commas (5143 is printed as 5,143). How to disable the commas?

10条回答
  •  天涯浪人
    2020-12-11 16:12

    This will remove all grouping (in your case commas).

    DecimalFormat df = new DecimalFormat();
    df.setGroupingUsed(false);
    

提交回复
热议问题