import java.util.HashSet;
import java.util.Random;
public class HashSetDemo {
public static void main(String[] args) {
HashSet<Integer> hs = new HashSet<>();
Random r = new Random();
Integer l = r.nextInt(16)+1;
System.out.println("蓝色号码球是:"+l);
while(hs.size()<6){
Integer h = r.nextInt(33)+1;
hs.add(h);
}
System.out.println("红色号码球是:");
for (Integer i : hs) {
System.out.println(i);
}
}
}
|
|