BlogJava 聯系 聚合 管理  

          Blog Stats

          News

           

          藍冰飛寒個人獨立博客地址,www.uphenan.com

          隨筆檔案

          文章檔案


          藍冰飛寒

          用心去做每一件事情



          import java.util.*;

          public class CollectionTest1{

              Collection c1 = new ArrayList();
              Collection c2 = new HashSet();
              
              public CollectionTest1(){
              Student s = new Student("李四",25000);
              c1.add(s);
              c1.add("張三");
              c2.add("王武");
              c2.add(new Student("趙柳",30000));
              printCollection(c1);
              printCollection(c2);
              
              
              
              }
              
              public void printCollection(Collection d){
                     System.out.println("-----------------");
                     Iterator it = d.iterator();
                     while(it.hasNext()){
                     System.out.println(it.next());
                     }
              
              }
              
              public static void main(String args[]){
              new CollectionTest1();
              
              }


          }
          class Student {
              public Student(String a,int b) {
                 this.name = a;
                 this.slary =b;
              }
             public String name;
              public int slary;
          public String toString(){
            String s="Name  "+name+"\n"+"GongZI  "+slary;
            return s;
            
            }
          }
          Tags -
          文章來源:http://www.tt-shopping.com/kevinlau/read.php/108.htm
          posted on 2009-05-09 21:59 藍冰飛寒 閱讀(42) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 光泽县| 庄河市| 司法| 麻城市| 藁城市| 佛冈县| 交口县| 阳东县| 辉南县| 五华县| 永寿县| 高雄市| 漠河县| 东海县| 北碚区| 青龙| 通化市| 杭锦后旗| 绩溪县| 亳州市| 东台市| 武邑县| 轮台县| 文昌市| 濮阳县| 亳州市| 东港市| 曲麻莱县| 梧州市| 汉沽区| 灵山县| 巍山| 罗田县| 西盟| 齐齐哈尔市| 万宁市| 新平| 兴城市| 苏州市| 鹤峰县| 水城县|