Java_常用类API之一

Math类中包含一些对数据进行数学运算的方法,而该类中的方法全都是静态的。像这样的类称之为工具类。

1 public static int abs(int a) 2 对一个数据求绝对值 3 public static double ceil(double n) 4 对一个小数向上取整 4.3 --> 5.0 5 public static double floor(double n) 6 对一个小数向下取整 4.3 --> 4.0 7 public static long round(double n) 8 对一个小数进行四舍五入 4.3 --> 4 ; 4.5 --> 5 9 10 public static int max(int a,int b) 11 求两个数的最大值 12 public static int min(int a,int b) 13 求两个数的最小值 14 15 public static double random() 16 生成[0,1)范围内的随机数

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyjsgf.html