直接贴几个小方法
/*** 获取0.0-1.0之间的随机小数*/private double test1() { double num = math.random(); return num;}/*** 获取两个数之间的随机小数*/private double test2(int min, int max) { return min + math.random() * (max - min);}/*** 获取两个数之间的随机整数*/private int test3(int min, int max) { return (int) (min + math.random() * (max - min));}
以上就是java如何使用math.random()生成随机数的详细内容。
