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();

  }

}

posted @ 2015-10-11 20:45  Dream_Lasting  阅读(220)  评论(0编辑  收藏  举报