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()

相关文章:

  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-05-29
  • 2021-09-01
  • 2022-02-10
  • 2021-08-27
  • 2022-01-01
猜你喜欢
  • 2021-11-30
  • 2022-01-06
  • 2021-11-05
相关资源
相似解决方案