您是第欢迎光临我的主页位访客
浩凡儿
天行健,君子以自强不息;地势坤,君子以厚德载物!
@Test
        public void run()
       {
              
              ArrayList<String> list= new ArrayList<String>();
              list.add( "美女");
              list.add( "帅哥");
              list.add( "芙蓉姐姐" );
               for (int i = 0; i < list.size(); i++) {
                     String str=list.get(i);
                     System. out.println(str);
              }
              System. out.println("==============================================" );
               for(String str:list)
              {
                     System. out.println(str);
                     
              }
              System. out.println("==================使用迭代器========================" );
              Iterator<String> it=list.iterator();
               while(it.hasNext())
              {
                     System. out.println(it.next());
                     
              }
       }
       
       
        @Test
        public void run1()
       {
              Set<String>set= new HashSet<String>();
              set.add( "aaaaaaaa");
              set.add( "bbbbbbbb");
              set.add( "cccccccc");
              set.add( "dddddddd");
              Iterator <String> iset=set.iterator();
               while(iset.hasNext())
              {
                     System. out.println(iset.next());
                     
              }
       }
        @Test
        public void run2()
       {
              
              Map<String,Integer> map= new HashMap<String,Integer>();
              map.put( "name", 1);
              map.put( "Height", 175);
              map.put( "Weight", 68);
              Set<String>set=map.keySet();
               for (String key:set) {
                     Integer value=map.get(key);
                     System. out.println(key +"==>>" +value);
              }
              Set<Entry<String,Integer>> entrys=map.entrySet();
               for(Entry<String,Integer> entry :entrys)
              {
                     System. out.println(entry.getKey()+entry.getValue());
                     
              }
              
       }
posted on 2016-06-28 15:12  浩凡儿  阅读(191)  评论(0编辑  收藏  举报