法一:加强遍历
for(Integer i:list){
System.out.println(i);
}
法二:lambda遍历1
list.forEach(e->{
System.out.println(e);
});
法三:lambda遍历2
list.forEach(System.out::println);
法四:普通遍历
for (int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
法五:通过迭代器while循环
Iterator<Integer> iterator = list.iterator();
while(iterator.hasNext()){
Integer value = iterator.next();
System.out.println(value);
}
法六:通过迭代器for循环
for(Iterator<Integer> it = list.iterator();it.hasNext();){
Integer value = it.next();
System.out.println(value);
}
法七:通过自带迭代器listIterator循环遍历
ListIterator<Integer> integerListIterator = list.listIterator();
while (integerListIterator.hasNext()){
System.out.println(integerListIterator.next());
}