爱嘉牛LA

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
View Code
package list_java270_2;

import java.util.HashSet;
import java.util.Iterator;
import java.util.TreeSet;

public class Test {


    public static void main(String[] args) {
           HashSet<Student> st=new HashSet<Student>();
           
           Student st1=new Student(10010, "xiao");
           st.add(st1);
           
           Student st2=new Student(10011, "hha");
           st.add(st2);
           
           Student st3=new Student(10014, "jia");
           st.add(st3);
           
           Student st4=new Student(10015, "hong");
           st.add(st4);
           
           Iterator<Student> t=st.iterator();
           
           while(t.hasNext()){
               Student r=t.next();
               System.out.println("ID:"+r.getID()+"  Name:"+r.getName());
           }
    }

}

 

posted on 2012-08-04 16:50  爱嘉牛LA  阅读(185)  评论(0编辑  收藏  举报