- package com.heima;
- import java.util.ArrayList;
- import java.util.Collection;
- import java.util.Iterator;
- @SuppressWarnings({ "rawtypes", "unused" })
- public class De_Dedaiqi {
- @SuppressWarnings("unchecked")
- public static void main(String[] args){
- Collection c = new ArrayList<>();
- c.add(new Student("zhangsan",23)); //Object obj = new Student();
- c.add(new Student("lisi",24));
- c.add(new Student("wangwu",25));
- Iterator it = c.iterator();
-
- while(it.hasNext()){
- Student s = (Student)it.next();
-
- System.out.println(s.getName() + s.getAge());
- }
-
-
- }
- }
复制代码 |
|