1.代码
package com.xtm.java.test;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
public class Test{
public static void main(String args[]){
Random random = new Random(System.currentTimeMillis());
//生成0~19的随机数
int val1 = random.nextInt(20);
ThreadLocalRandom threadLocalRandom = ThreadLocalRandom.current();
//生成4~20的随机数
int val2 = threadLocalRandom.nextInt(4, 20);
System.out.println(val1+"-----"+val2);
}
}