//1.The first way
Iterator<ArrayList<Student>> it = cla.iterator();
int count = 1;
while(it.hasNext()) {
Iterator<Student> itt = it.next().iterator();
System.out.println(" "+count+" ");
while(itt.hasNext()) {
System.out.println(itt.next().getName()+"----------" +itt.next().getAge());
}
count++;
}
System.out.println("---------------------");
//2.The second way
for(int i=0 ; i<cla.size() ; i++) {
System.out.println("Class"+(i+1));
for(int j=0 ; j<cla.get(i).size() ; j++) {
Student s = cla.get(i).get(j);
System.out.println(s.getName()+"------------"+s.getAge());
}
}
//3.The third way
int cou = 1;
for(ArrayList<Student> cl: cla) {
System.out.println("Class:"+cou);
for(Student sl:cl) {
System.out.println(sl.getAge()+"---------------"+sl.getName());
}
}
// System.out.println(st);