java中保留小数点后2位的三种方式 1.使用String的format方法 double a = 12.535; double b = 12.534; //直接利用String.format System.out.println(String.format("%.2f",a)