zoukankan      html  css  js  c++  java
  • List Map迭代 ( 增强For只适合取数据 )

    @Test

    public void test1(){

      List list = new ArrayList();

      list.add(DateType);

      ...

      for(Object obj : list){

        DateType dateType = (DateType)obj;

      }

    }

    @Test

    public void test2(){

      Map map = new LinkedHashMap();

      map.add(StringValue,DateType);

      ...

      Set set = map.keySet();

      Iterator it = set.iterator();

      while(it.hasNext()){

        String key = (DateType)it.next();

        DateType value = (DateType)map.get(key);

      }

    }

    @Test

    public void test3(){

      Map map = new LinkedHashMap();

      map.add(StringValue,DateType);

      ...

      Set set = map.entrySet();

      Iterator it = set.iterator();

      while(it.hasNext()){

        Map.Entry entry = (Entry)it.next();

        String key = (String)entry.getKey();

        DateType value = (DateType)entry.getValue();

      }

    }

    @Test

    public void test4(){

      Map map = new LinkedHashMap();

      map.add(StringValue,DateType);

      ...

      for(Object obj : map.keySet()){

        String key = (String)obj;

        DateType value = (DateType)map.get(key);

      }

    }

    @Test

    public void test5(){

      Map map = new LinkedHashMap();

      map.add(StringValue,DateType);

      ...

      for(Object obj : map.entrySet()){

        Map.Entry entry = (Entry)obj;    

        String key = (String)entry.getKey();

        DateType value = (DateType)entry.getValue();

      }

    }

    @Test

    public void test6(){

      Map map = new LinkedHashMap();

      map.add(StringValue,DateType);

      ...

      for(Object obj : map.entrySet()){

        Map.Entry entry = (Entry)obj;    

        String key = (String)entry.getKey();

        DateType value = (DateType)entry.getValue();

      }

    }

  • 相关阅读:
    [bzoj1500][luogu2042][cogs339][codevs1758]维修数列(维护数列)
    无旋treap的简单思想以及模板
    [hdu2036]改革春风吹满地
    (treap)[bzoj3224][洛谷3369][cogs1829]Tyvj 1728 普通平衡树
    [bzoj3875][Ahoi2014]骑士游戏
    [bzoj1433][ZJOI2009]假期的宿舍
    <struct、union、enum>差异
    LeetCode(50) Pow(x,n)
    LeetCode(49)Group Anagrams
    LeetCode(48)Rotate Image
  • 原文地址:https://www.cnblogs.com/Dream-Lasting/p/4869992.html
Copyright © 2011-2022 走看看