且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从双精度型中删除尾随零

更新时间:2023-01-18 20:13:16

使用DecimalFormat

  double answer = 5.0;
   DecimalFormat df = new DecimalFormat("###.#");
  System.out.println(df.format(answer));