集合的用法

    xiaoxiao2022-07-14  184

    泛型的高级用法

    package com.ybh2; import java.util.ArrayList; import com.ybh1.Person_1; public class Demo2_Arr { public static void main(String[] args) { ArrayList<ArrayList<Person_1>> list = new ArrayList<>();//第一种泛型是person_1,外部是ArrayList ArrayList<Person_1> a = new ArrayList<>(); ArrayList<Person_1> b = new ArrayList<>(); a.add(new Person_1("孙丽丽",01)); a.add(new Person_1("吴仪",02)); b.add(new Person_1("徐欣荣",03)); list.add(a); list.add(b); for (ArrayList<Person_1> p:list) {//要循环两次遍历 for (Person_1 i : p) { System.out.println(i); } } } }
    最新回复(0)