且构网

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

在 Java 中添加小数位(3 个小数位)

更新时间:2023-09-04 14:39:10

使用 String.format 将您的输出格式化为 3 个小数位.输出四舍五入.

Use String.format to format your output to 3 decimal places. The output is rounded.

System.out.println("Your average for the game or season is: " +
    String.format("%.3f", avg));