[](()2.集合的遍历
- 其实就是依次获取集合中的每一个元素。
Object[] arr = coll.toArray(); //将集合转换成数组
for (int i = 0; i < arr.length; i++) {
Student s = (Student)arr[i]; //强转成Student
System.out.println(s.getName() + “,” + s.getAge());
}
[](()3.Collection集合的带All功能测试
- A:案例演示
带All的功能演示
boolean addAll(Collection c)
boolean removeAll(Collection c)
boolean containsAll(Collection c)
boolean retainAll(Collection c)
[](()4.集合的遍历之迭代器遍历
-
A:迭代器概述
-
集合是用来存储元素,存储的元素需要查看,那么就需要迭代(遍历)
for(Iterator it = c.iterator();i