标签:str out format ble rgs form orm ring mat
String.format("%.nf",d);----表示保留N位
public static void main(String[] args) {
double d = 3.1415926;
String result1 = String.format("%.2f", d);
String result = String.format("%.3f", d);
System.out.println(result1);//3.14
System.out.println(result);//3.142
}
标签:str out format ble rgs form orm ring mat
原文地址:https://www.cnblogs.com/eternityz/p/12238749.html