生成随机数
import java.util.Random;
public static int CreateNum()
{
Random r = new Random();
int num = r.nextInt(); //这是一个很大的随机数 有正有负
num = num % 10; // -10 -- 10 间的随机整数
return num;
}
//或者
public static int ran()
{
return (int)(Math.random()*100);
//创建一个0~99之间的随机数
}
最后
以上就是秀丽毛豆最近收集整理的关于随机数的全部内容,更多相关随机数内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复