java.lang.Math.random方法
Modifier and Type | 方法 | 描述 |
---|---|---|
static double |
random() |
返回值为 double 的正值,大于等于 0.0 ,小于 1.0 。 |
random()
public class TestMax {
public static void main(String[] args) {
test();
}
//测试 random()方法
public static void test(){
// 生成0~100的随机数
int num = (int)(100 * Math.random());
System.out.println("0~100随机数:"+num);
}
}
0~100随机数:27