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()); } } }
感谢您的阅读,您的支持是我写博客动力。