gpt4 book ai didi

java - Google Multimap 中的通用

转载 作者:搜寻专家 更新时间:2023-11-01 02:30:18 24 4
gpt4 key购买 nike

你有理由吗 MultiMap是不是完全通用?

containsEntry(Object key, Object value)
containsKey(Object key)
remove(Object key, Object value)
removeAll(Object key)

最佳答案

this answer Guava 的 Multimap 也是如此。另外,您可能需要阅读 Kevin Bourrillion's blog entry (他是 Guava lead dev)解释了同样的问题(注意 add 使用通用类型 E):

The real difference is that add() can cause "damage" to the collection when called with the wrong type, and contains() and remove() cannot.

Uniformly, methods of the Java Collections Framework (and the Google Collections Library too) never restrict the types of their parameters except when it's necessary to prevent the collection from getting broken.

关于java - Google Multimap 中的通用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11095324/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com