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)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 新蔡县| 荥阳市| 民丰县| 诸暨市| 张家口市| 苏尼特左旗| 雷山县| 普陀区| 五河县| 威海市| 荥经县| 玉林市| 永安市| 福州市| 巴林左旗| 秦皇岛市| 景东| 张掖市| 德保县| 紫金县| 东乌珠穆沁旗| 上杭县| 安塞县| 京山县| 九龙城区| 竹山县| 定远县| 娱乐| 古田县| 绥德县| 汾西县| 乡城县| 彩票| 辽源市| 泰顺县| 广德县| 将乐县| 长乐市| 五常市| 仙居县| 邵武市|