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 藍冰飛寒 閱讀(39) 評論(0)  編輯  收藏

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


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 德令哈市| 松原市| 卓资县| 梅河口市| 都江堰市| 英吉沙县| 晋中市| 阿瓦提县| 那曲县| 沂水县| 正镶白旗| 长乐市| 崇信县| 灵山县| 滦南县| 漳平市| 新疆| 当阳市| 旺苍县| 贵德县| 开鲁县| 顺义区| 宣化县| 北安市| 涟水县| 淄博市| 庆元县| 托克托县| 天津市| 雷波县| 柳江县| 新沂市| 平遥县| 沙河市| 华容县| 丰县| 许昌市| 江源县| 景德镇市| 肃宁县| 繁昌县|