实验二iterator迭代器做完
This commit is contained in:
@@ -7,7 +7,16 @@ public class WalkCollection {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ArrayList arrayListExample = new ArrayList();
|
ArrayList arrayListExample = new ArrayList();
|
||||||
// ---------------------Begin------------------------
|
// ---------------------Begin------------------------
|
||||||
|
// arrayListExample.add("aaa");
|
||||||
|
// arrayListExample.add("bbb");
|
||||||
|
// arrayListExample.add("ccc");
|
||||||
|
// arrayListExample.add("ddd");
|
||||||
// 使用迭代器iterator遍历arrayListExample集合
|
// 使用迭代器iterator遍历arrayListExample集合
|
||||||
|
Iterator itr = arrayListExample.iterator();
|
||||||
|
while (itr.hasNext()) {
|
||||||
|
System.out.println(itr.next());
|
||||||
|
}
|
||||||
|
|
||||||
// 使用foreach遍历arrayListExample集合
|
// 使用foreach遍历arrayListExample集合
|
||||||
// ---------------------End------------------------
|
// ---------------------End------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user