math类

成员方法

 


* public static int abs(int a)//取绝对值

* public static double ceil(double a)//向上取整

* public static double floor(double a)//向下取整

* public static int max(int a,int b) min自学 //取出最大值

* public static double pow(double a,double b)//计算a的b次方

* public static double random()//随机出0.0~1.0之间的随机数 ,不包含1.0

* public static int round(float a) 参数为double的自学 //四舍五入

* public static double sqrt(double a)//开平方

 


如何获取一个1-100之间的随机数?

int number = (int)(Math.random()*100)+1;

注:random():返回带正号的 double 值,该值大于等于 0.0 且小于 1.0。


posted on 2017-02-16 19:10  LoaderMan  阅读(151)  评论(0编辑  收藏  举报

导航