时间:2021-04-23 09:29:57 | 栏目:JAVA代码 | 点击:次
1、通过System.currentTimeMillis()来获取一个当前时间毫秒数的long型数字。
long a = System.currentTimeMillis(); System.out.println(a);
2、通过Math.random()返回一个0到1之间的double值。
int b = (int)(Math.random()*99+1); System.out.println(b);
3、通过Random类来产生一个随机数。
Random random = new Random(); int c = random.nextInt(100)+1; System.out.println(c);