zbb20181227 map,LinkedHashMap按顺序存放key,MultiValueMap 一个key对多个value

MultiValueMap 一个key对多个value 需要引入pom

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.2</version>
</dependency>

MultiValueMap multiValueMap = new MultiValueMap();
multiValueMap.put("123", "String");
multiValueMap.put("123", "String");
multiValueMap.put("abc", "String");
multiValueMap.put("abcde", "String");
multiValueMap.put("1234", "String");
multiValueMap.put("abcd", "String");
multiValueMap.put("1234", "String");
System.out.println(multiValueMap.getCollection("123"));
System.out.println(multiValueMap.keySet());

LinkedHashMap按顺序存放key,

Map<String, String> multiValueMap = new LinkedHashMap<String, String>();
multiValueMap.put("123", "String");
multiValueMap.put("123", "String");
multiValueMap.put("abc", "String");
multiValueMap.put("abcde", "String");
multiValueMap.put("1234", "String");
multiValueMap.put("abcd", "String");
multiValueMap.put("1234", "String");
System.out.println(multiValueMap.keySet());

posted @ 2018-12-27 13:06  DaryllD  阅读(1631)  评论(0编辑  收藏  举报