您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

java如何使用Math.random()生成随机数

2025/10/13 23:37:53发布25次查看
使用math.random()生成随机数
直接贴几个小方法
/*** 获取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()生成随机数的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product