public static void main(String[] args) {
ArrayList<ArrayList<Person>> s = new ArrayList<>();
ArrayList<Person> first = new ArrayList<>();
first.add(new Person("小明", 12));
first.add(new Person("小红", 12));
first.add(new Person("小张", 12));
first.add(new Person("小李", 12));
first.add(new Person("小刘", 12));
first.add(new Person("小邹", 12));
first.add(new Person("小赵", 12));
first.add(new Person("小王", 12));
ArrayList<Person> second = new ArrayList<>();
second.add(new Person("老周", 32));
second.add(new Person("老李", 32));
second.add(new Person("老王", 32));
second.add(new Person("老赵", 32));
second.add(new Person("老钱", 32));
second.add(new Person("老抠", 32));
s.add(first);
s.add(second);
for (ArrayList<Person> person : s) {
System.out.println(person);
}
}
用迭代器怎么遍历?
求逻辑... |
|