import java.util.*;
public class test {
public static void main(String[] args) {
int n = 30;
Random rand = new Random();//新建一个随机类
boolean[] bool = new boolean[n];
int randInt = 0;
for(int i = 0; i < 5 ; i++) {
do {
randInt = rand.nextInt(n);//产生一个随机数
}while(bool[randInt]);
bool[randInt] = true;
System.out.println(randInt);
}
}
}
public class test {
public static void main(String[] args) {
int n = 30;
Random rand = new Random();//新建一个随机类
boolean[] bool = new boolean[n];
int randInt = 0;
for(int i = 0; i < 5 ; i++) {
do {
randInt = rand.nextInt(n);//产生一个随机数
}while(bool[randInt]);
bool[randInt] = true;
System.out.println(randInt);
}
}
}