package conection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class Ergodic {
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
* java集合类的四种遍历方式
*
*/
List<Integer> list = new LinkedList<Integer>();
list.add(10);
list.add(30);
list.add(50);
list.add(90);
System.out.println("*********方法一 ********");
for(Iterator iterator = list.iterator();iterator.hasNext();){
System.out.println(iterator.next());
}
System.out.println("*********方法一 ********");
Iterator iterator = list.iterator();
while(iterator.hasNext()){
System.out.println(iterator.next());
}
System.out.println("*********方法一 ********");
for (Object object : list) {
System.out.println(object);
}
System.out.println("*********方法一 ********");
for (int i = 0 ;i<list.size();i++) {
System.out.println(list.get(i));
}
}
}