相关疑难解决方法(0)

什么是PECS(制作人扩展消费者超级)?

我在阅读泛型时遇到了PECS(制片extends人和消费者的super简称).

能否给我一个人解释如何使用佩奇之间解决困惑extendssuper

java generics super pecs bounded-wildcard

680
推荐指数
11
解决办法
9万
查看次数

Java Map编译器错误与泛型

// I know that this method will generated duplicate 
// trim keys for the same value but I am just
// trying to understand why we have a compile error:
// The method put(String, capture#11-of ?) in the type
// Map<String,capture#11-of ?> is not applicable for the arguments
// (String, capture#12-of ?)

void trimKeyMap(Map<String, ?> map){
  for (String key : map.keySet()) {
    map.put(StringUtils.trim(key), map.get(key)); // compile error
  }
}
Run Code Online (Sandbox Code Playgroud)

为什么我们想要的价值 map.get(key)来自不同的类型?

java generics map

3
推荐指数
1
解决办法
1236
查看次数

标签 统计

generics ×2

java ×2

bounded-wildcard ×1

map ×1

pecs ×1

super ×1