我有一个数组列表。我想将它的每个元素设置为 0。现在我有:
ArrayList <T extends Number> arr = new ArrayList();
for(int i = 0; i < some_other_array.size(); i++)
{
arr.add(0)
}
编译器抱怨说
error: no suitable method found for set(int,int)
arr.add(0);
^
method ArrayList.set(int,T) is not applicable
(actual argument int cannot be converted to T by method invocation conversion)
where T is a type-variable:
T extends Number