JAVA如何保留小数点后两位 HYHsniper public class T6 { public static void main(String[] args) { double x1=1.126; System.out.println(String.format("%.2f",x1)); DecimalFormat df = new DecimalFormat(".00"); System.out.println(df.format(x1)); } }