public static void main(String[] args){
double d = 18896.5578;
DecimalFormat df = new DecimalFormat("#.00");
System.out.println(df.format(d));
}
这样也可以
public static void main(String[] args){
double num = 5.75557;
System.out.println(Math.floor(num));//取整
BigDecimal b=new BigDecimal(num);
num=b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
System.out.println(num);
}