package Student;
import java.util.Comparator;
import java.util.Random;
import java.util.TreeSet;
public class Random1 {
/**
* @param args
*/
public static void main(String[] args) {
TreeSet<Integer> ts = new TreeSet<>(new Comparator<Integer>() {
public int compare(Integer t1, Integer t2) {
return t1-t2;
}
});
Random r = new Random();
while(ts.size() < 5){
ts.add(r.nextInt(30)+21);
}
for (Integer integer : ts) {
System.out.println(integer);
}
}
}
|
|