Java Map

package com.test.map;

import java.util.Map;
import java.util.Set;
import java.util.HashMap;
import java.util.Iterator;

public class TestDemo {

    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<String,Integer>();
        map.put("one", 1);
        map.put("two", 2);
        map.put("three", 3);
        Set<Map.Entry<String, Integer>> set = map.entrySet();
        Iterator<Map.Entry<String, Integer>> iter = set.iterator();
        while(iter.hasNext()){
            Map.Entry<String, Integer> me = iter.next();
            System.out.println(me.getKey()+"="+me.getValue());
        }
    }
}

 

posted @ 2015-12-22 11:17  finalboss1987  阅读(193)  评论(0编辑  收藏  举报