org.apache.commons.collections.MultiMap 使用范例

	MultiMap map = new MultiValueMap();
	map.put("1,1", "aaa");
	map.put("1,1", "bbb");
	map.put("2,2", "ccc");
	map.put("2,2", "ddd");
	map.put("3,3", "eee");
	System.err.println(map);
	//		Iterator iterator = map.entrySet().iterator();
	//		while (iterator.hasNext()) {
	//			System.err.println(iterator.next().getClass());
	//		}
	System.err.println(map.get("1,1"));
	System.err.println("---------------------------------");
	Iterator iterator = map.keySet().iterator();
	while (iterator.hasNext()) {
		//			System.err.println(iterator.next());
		Object key = iterator.next();
		Object object = map.get(key);
		if (object instanceof List) {
			List<String> valuelist = (List<String>) object;
			for (Object value : valuelist) {
				System.out.println(key + "----" + value);
			}
		} else if (object instanceof String) {
			System.out.println(key + "====" + object.toString());
		}
	}

 

你可能感兴趣的:(apache)