Java 将参数化映射值传递给通配符签名参数
我试图在方法签名中使用通配符类型,并传递不同的参数化类型。如果它只是一个GenericItemWrapper,那么它可以正常工作,但是如果GenericItemWrapper本身是一个类型参数,那么它就会失败。以下是eclipse抱怨的内容:Java 将参数化映射值传递给通配符签名参数,java,generics,Java,Generics,我试图在方法签名中使用通配符类型,并传递不同的参数化类型。如果它只是一个GenericItemWrapper,那么它可以正常工作,但是如果GenericItemWrapper本身是一个类型参数,那么它就会失败。以下是eclipse抱怨的内容: The method DoStuff(Map<String, Test.GenericItemWrapper<?>>) in the type Test is not applicable for the arguments (M
The method DoStuff(Map<String, Test.GenericItemWrapper<?>>) in the type Test
is not applicable for the arguments (Map<String, Test.GenericItemWrapper<String>>)
方法DoStuff(MapEclipse没有抱怨:
public <T> void DoStuff(Map<String, GenericItemWrapper<T>> aParam) {
;
}
public void DoStuff(地图aParam){
;
}
Eclipse没有抱怨:
public <T> void DoStuff(Map<String, GenericItemWrapper<T>> aParam) {
;
}
public void DoStuff(地图aParam){
;
}
试试这个:
public void DoStuff(Map
)尝试以下操作:
public void DoStuff(Map
)嗯..它确实是第一位的。嗯..它确实是第一位的。