导致问题的Java泛型

导致问题的Java泛型,java,generics,Java,Generics,我的IDE抱怨“NCM_Callable无法转换为Callable,据我所知,有问题的行是ecs.submit: public final void submitCallable(Callable<? extends ReturnInterface<?>> c) { // create a map for this future ecs.submit(c); // Error here is Callable<CAP#1 cannot be conv

我的IDE抱怨“NCM_Callable无法转换为
Callable,据我所知,有问题的行是
ecs.submit

public final void submitCallable(Callable<? extends ReturnInterface<?>> c) {
    // create a map for this future
    ecs.submit(c); // Error here is Callable<CAP#1 cannot be converted to Callable<ReturnInterface<?>>
   this.callables.add(c); // this is fine on my machine
}

据我所知,问题行是
ecs.submit

public final void submitCallable(Callable<? extends ReturnInterface<?>> c) {
    // create a map for this future
    ecs.submit(c); // Error here is Callable<CAP#1 cannot be converted to Callable<ReturnInterface<?>>
   this.callables.add(c); // this is fine on my machine
}

首先创建一个。您可能会在过程中解决您的问题。可能的重复项不是重复项。但它解决了您的问题吗?查看第二个答案,您必须将方法签名改为使用
callable顺便说一句,
首先创建一个。您可能会在过程中解决您的问题。可能的重复项其中一个不是重复的。但是它解决了你的问题吗?看看第二个答案,你必须将方法签名改为使用
可调用顺便说一句,
我被弄糊涂了,结果只是接受了一个可调用的。很好有人能解释为什么我的代码不起作用。我被弄糊涂了nd最终接受了一个可调用的。很好,有人能解释为什么我的代码不起作用。
public class NCM_Callable implements Callable<ReturnInterface<ResultSet>>, ReturnInterface<ResultSet> {
public final void submitCallable(Callable<? extends ReturnInterface<?>> c) {
    // create a map for this future
    ecs.submit(c); // Error here is Callable<CAP#1 cannot be converted to Callable<ReturnInterface<?>>
   this.callables.add(c); // this is fine on my machine
}
public final <T extends ReturnInterface<?>> void // this is how you name and bind the type
   submitCallable(Callable<T> c) { // here you are referring to it
    // create a map for this future
    ecs.submit((Callable<ReturnInterface<?>>) c); // here you need to cast. 
    ...
}
private static class ReturnInterfaceImpl implements ReturnInterface<String>  {

};

public void foo() {
    Callable<ReturnInterfaceImpl> c = new Callable<ReturnInterfaceImpl>() {
        @Override
        public ReturnInterfaceImpl call() throws Exception {
            return null;
        }
    };
    submitCallable(c);
}