增强for循环
# 增强for循环
```java
package com.FreeGiao.CollecationDemo.ListDemo;
import java.awt.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ListDemo03 {
public static void main(String[] args) {
List<Student03> li = new ArrayList<>();
Student03 s1 = new Student03("ff", 18);
Student03 s2 = new Student03("gg", 19);
Student03 s3 = new Student03("hh", 20);
li.add(s1);
li.add(s2);
li.add(s3);
for (int i = 0; i < li.size(); i++) {
Student03 j = li.get(i);
System.out.println(j.getName()+j.getAge());
}
Iterator<Student03> it = li.iterator();
while (it.hasNext()){
Student03 k = it.next();
System.out.println(k.getName()+k.getAge());
}
for (Student03 l : li){
System.out.println(l.getName()+l.getAge()
);
}
}
}
```