java随机数

Math.random随机产生一个0<=x<1的数。

产生一个随机整数

(int)(2+Math.random()*(5-2+1)) //将2和5替换

//还可以通过Random类
Random random=new Random();
random.nextInt(10)+1; //0<=nextInt<10

//可以获取一个当前时间毫秒数的long型数字
System.currentTimeMillis()
原文地址:https://www.cnblogs.com/liehen2046/p/11084036.html