import java.util.Random;
/**
*通过调用random函数,检测随机产生的数字,如果出现过,就标记flag为 true,依次作为鉴别标准
*/
public class random {
public static void main(String[] args) {
Random rand = new Random();//新建一个随机类
boolean[] bool = new boolean[20];
int randInt = 0;//新建变量用于临时存储产生的随机数
for(int i = 0; i < 6 ; i++) {
do {
//randInt = rand.nextInt(20);//产生一个随机数
randInt = (int) (Math.random()*15);
}while(bool[randInt]);
bool[randInt] = true;
System.out.println(randInt);
}
}