import java.util.ArrayList;
public class Ticket {
    public static void main(String[] args) {
        ArrayList<Integer> red = new ArrayList<>();
        // 随机六个数添加到数组中
        while (true) {
            int num = (int) (Math.random() * 33 + 1);
            // 判断数组中是否已存在有与随机产生相等的值
            if (!red.contains(num)) {
                //没有重复的就添加到数组中
                red.add(num);
                //添加到六个就结束循环
                if (red.size() == 6) {
                    break;
                }
            }
        }
        // 蓝色球16中随机一个
        System.out.print("红色球");
        int bul = (int) (Math.random() * 16 + 1);
        //遍历ArrayList数组获取每一个值
        for(int a:red){
            System.out.print(a+" ");
        }
        System.out.print( "蓝色球" + bul);
    }
}
//运行结果
/*    红色球20 28 7 16 19 27 蓝色球5   */