Double pi = 3.1415926535; DecimalFormat df = new DecimalFormat("###.0"); System.out.println(df.format(pi));
输出结果为3.1
其中#为没有数据时不填充
其中0为没有数据的时候以0填充
Double pi = 3.1415926535; DecimalFormat df = new DecimalFormat("###.0"); System.out.println(df.format(pi));
输出结果为3.1
其中#为没有数据时不填充
其中0为没有数据的时候以0填充