public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("wo");
list.add("shi");
list.add("yi");
list.add("ge");
list.add("hao");
list.add("ren");
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
System.out.println("--------------------");
Iterator<String> iterator = list.iterator();
while (iterator.hasNext()){
System.out.println(iterator.next());
}
System.out.println("------------------------");
for (String s : list){
System.out.println(s);
}
}
List集合遍历的几种方式
最新推荐文章于 2024-07-02 19:19:45 发布