在0-33里面产生6个随机数放ArrayList并遍历

public class Demo05ArrayListTest1 {

    public static void main(String[] args) {
        ArrayList<Integer> List=new ArrayList<>();
        Random r=new Random();
        for (int i = 0; i < 6; i++) {
            int num=r.nextInt(32)+1;
            List.add(num);
        }
        System.out.println(List);
    }
    
}

发布了28 篇原创文章 · 获赞 1 · 访问量 482

猜你喜欢

转载自blog.csdn.net/qq_45145809/article/details/104863886