代码自取
public class TwoToneBall{
public static void main(String[] args) {
//Map HashMap
//Set TreeSet HashSet
//List ArrayList
Random rand = new Random();
int i = 0;
//红 1-33 6
//蓝 1-16 1
Map<String, List<Set<Integer>>> v = new HashMap<>();
while (true) {
List<Set<Integer>> list = new ArrayList<>();
Set<Integer> red = new TreeSet<>();
while(red.size() != 6){
red.add(rand.nextInt(1,34));
}
list.add(red);
Set<Integer> blue = new HashSet<>();
blue.add(rand.nextInt(1,17));
list.add(blue);
v.put("" + ++i, list);
if (i == 10) //定义有几组
break;
}
//System.out.println(v);
v.forEach((k,vv)->{
System.out.printf("%s = %s%n",k,vv);
});
}
}
结果如下