分组

public class fenzu {
    public static void main(String[] args) {
        String[] teamarray ={"科特迪瓦","阿根廷","澳大利亚","塞尔维亚","荷兰","尼日利亚","日本","美国","中国","新西兰",
                "巴西","比利时","韩国","喀麦隆","洪都拉斯","意大利"};
        List countryList = new ArrayList();
        Map> teammap = new HashMap>();
        for (String string:teamarray){
            countryList.add(string);
        }
        for (int i = 0;i < 4;i++){
            List list = new ArrayList();
            for (int j = 0;j < 4;j++){
                Random random = new Random();
                int num = random.nextInt(countryList.size());
                String teamname = countryList.get(num);
                list.add(teamname);
                countryList.remove(teamname);
            }
            teammap.put(i+1,list);
        }

        for (Integer in : teammap.keySet()){
            System.out.println(in+"---"+teammap.get(in));
        }


    }
}

你可能感兴趣的:(分组)