/**
* Set nested arraylist nested ArrayList
Case
* Our disciplines, disciplines are divided into a class
* A large collection of whole disciplines
* Several classes are divided into small sets of each
*/
public static void Main (string[] args) {
arraylist<arraylist<person>> list = new arraylist<> ();
arraylist<person> first = new arraylist<> ();//Create a class
First.add (New Person ("Yang Mi", 30));
First.add (New person ("Li Bingbing", 33));
First.add (New person ("Fan Bingbing", 20));
arraylist<person> second = new arraylist<> ();
Second.add (New person ("Huang Xiaoming", 31));
Second.add (New person ("Zhao Wei", 33));
Second.add (New Person ("Chen Kun", 32));
Add a class to a collection of disciplines
List.add (first);
List.add (second);
Traverse the collection of disciplines
for (arraylist<person> a:list) {
for (person P:a) {
SYSTEM.OUT.PRINTLN (P);
}
}
}
Java ArrayList nested ArrayList