我在 putInstance 方法调用中收到以下编译错误“MutableClassToInstanceMap 类型中的方法 putInstance(Class, T) 不适用于参数 (Class, Number)”。有谁知道我做错了什么?谢谢!
public class TestMutableClassToInstanceMap {
public final MutableClassToInstanceMap<Number> identifiers = MutableClassToInstanceMap.create();
public static void main(String[] args) {
ArrayList<Number> numbers = new ArrayList<Number>();
numbers.add(new Integer(5));
TestMutableClassToInstanceMap test = new TestMutableClassToInstanceMap(numbers);
}
public TestMutableClassToInstanceMap(Collection<Number> numbers){
for (Number number : numbers) {
this.identifiers.putInstance(number.getClass(), number); //error here
}
this.identifiers.putInstance(Double.class, 5.0); // This works
}
}