System.out.println("---------------五种四舍五入保留小数的方法-------------------");
System.out.println("-------第一种String法-------");
String s1=String.format("%.2f", 3.14563);
System.out.println(s1);
System.out.println("-------第二种Math法---------");
System.out.println(Math.round(3.1546*100)/100.0);
System.out.println("-------第三种BigDecimal-----");
BigDecimal bigDecimal = new BigDecimal("3.1563245");
BigDecimal bigDecimal1=bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP);
System.out.println(bigDecimal1);
System.out.println("-------第四种printf---------");
System.out.printf("%.2f",3.1456789);
System.out.println();
System.out.println("-------第五种DecimalFormat--");
DecimalFormat decimalFormat = new DecimalFormat("#.##");
String s2=decimalFormat.format(3.15646589);
System.out.println(s2);