guava HashMultimap Demo

guava-libraries http://code.google.com/p/guava-libraries/

public class MultiMapDemo {

    public static void main(String[] args) {
        HashMultimap<String, String> map = HashMultimap.create();
        map.put("a", "AAAAA");
        map.put("a", "AAA");
        map.put("a", "AA");
        map.put("b", "BBBBBB");
        map.put("b", "BBBB");
        Set<String> values = map.get("a");
        for (String value : values) {
            System.out.println(value);
        }
        System.out.println("-----------------------");
        Set<String> keys = map.keySet();
        for (String key : keys) {
            System.out.println(key);
        }
    }
}
posted @ 2012-10-26 15:22  Leo Forest  阅读(240)  评论(0编辑  收藏  举报