加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

Java Map是多值并支持泛型?

发布时间:2020-12-14 23:45:30 所属栏目:Java 来源:网络整理
导读:我注意到公共有一个 MultiValueMap,但它不支持泛型.有这样的地图吗? 解决方法 你试过Guava的Multimap吗? A collection similar to a Map,but which may associate multiple values with a single key. If you call put(K,V) twice,with the same key but d
我注意到公共有一个 MultiValueMap,但它不支持泛型.有这样的地图吗?

解决方法

你试过Guava的Multimap吗?

A collection similar to a Map,but which may associate multiple values with a single key. If you call put(K,V) twice,with the same key but different values,the multimap contains mappings from the key to both values.

Depending on the implementation,a multimap may or may not allow duplicate key-value pairs. In other words,the multimap contents after adding the same key and value twice varies between implementations. In multimaps allowing duplicates,the multimap will contain two mappings,and get will return a collection that includes the value twice. In multimaps not supporting duplicates,the multimap will contain a single mapping from the key to the value,and get will return a collection that includes the value once.

http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Multimap.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读