1. 使用Math.round() Math.round()是Java标准库中最常用的四舍五入方法,它有两个重载版本,一个用于处理float类型,另一个用于处理double类型。 1.1 Math.round(float a) 这个方法将float类型的数字四舍五入为最接近的整数,如果小数部分 >= 0.5,则向上取整;否则向下取整。 public class RoundExample { public ...