public static void main(String[] args) {
double d = 3.1856666;
// double类型的数据保留两位小数
System.out.println(new DecimalFormat("#.00").format(d));
// 或
System.out.println(String.format("%.2f", d));
}
Connected to the target VM, address: '127.0.0.1:57442', transport: 'socket'
3.19
Disconnected from the target VM, address: '127.0.0.1:57442', transport: 'socket'
3.19