java Map迭代

//LinkedHashMap先入先出

public class Test {

public static void main(String[] args) {
Map<String,Object> map = new HashMap<String,Object>();
map.put("aaa", "111");
map.put("bbb", "222");
map.put("ccc", "333");
for(Entry<String,Object> e :map.entrySet()){
System.out.println("key:"+e.getKey()+",value:"+e.getValue());
}
}


 public static void main_1(String[] args) { 
  LinkedHashMap<String,Object> map = new LinkedHashMap<String,Object>();
  map.put("1", "one"); 
  map.put("2", "tow");
  map.put("3", "three");
  for(Entry<String,Object> e: map.entrySet()){ 
  System.out.println(e.getKey()+":"+e.getValue()); 
     } 
   } 
}
  

  

  

  

posted @ 2016-11-10 09:54  N神3  阅读(3346)  评论(0编辑  收藏  举报