使用import java.text.DecimalFormat;和System.out.println(new DecimalFormat("0.0000").format(f3)); 前一个括号是格式,后一个是要格式的内容