@SuppressWarnings(“unchecked”)
import java.util.ArrayList;
import java.util.Collection;
public class Demo1_Collection {
//集合的遍历
public static void main(String[] args) {
@SuppressWarnings(“rawtypes”)
Collection c =new ArrayList();
c.add(new Student(“张三”,23));
c.add(new Student(“李四”,24));
c.add(new Student(“王五”,25));
Object[] arr =c.toArray();
for(int i=0; i<arr.length;i++ ){
Student s=(Student)arr[i];
System.out.println(s.getName()+" "+s.getAge());
}
}
}