java保留兩位小數四種方法
...
...
轉載 本文列舉了幾個方法: 1. 使用java.math.BigDecimal 2. 使用java.text.DecimalFormat 3. 使用java.text.NumberFormat 4. 使用java ...
轉載自:https://www.cnblogs.com/exmyth/p/13747331.html 本文列舉了幾個方法: 1. 使用java.math.BigDecimal 2. 使用java.text.DecimalFormat 3. 使用 ...
java保留兩位小數4種方法 方法一:String的format方法(推薦) double f = 111231.5585; System.out.println(String.format("%.2f", f)); 方法二:DecimalFormat的format方法 ...
方法一:String的format方法(推薦) double f = 111231.5585; System.out.println(String.format("%.2f", f)); ...
...
1、int型或者Integer型 import java.text.DecimalFormat; public class IntDivideTest { public static void main(String[] args) { int ...