我收到以下編譯錯誤putInstance方法調用的參數(Class,Number)「類型MutableClassToInstanceMap中的方法putInstance(Class,T)」不適用。有誰知道我在做什麼錯?謝謝!使用MutableClassToInstanceMap與泛型編譯錯誤
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
}
}