<分区>
Possible Duplicate:
Is it possible to solve the “A generic array of T is created for a varargs parameter” compiler warning?
考虑这是给定的:
interface A<T> { /*...*/ }
interface B<T> extends A<T> { /*...*/ }
class C { /*...*/ }
void foo(A<T>... a) { /*...*/ }
现在,一些其他代码想要使用 foo
:
B<C> b1 /* = ... */;
B<C> b2 /* = ... */;
foo(b1, b2);
这给了我警告
Type safety : A generic array of A is created for a varargs parameter
所以我将调用更改为:
foo((A<C>) b1, (A<C>) b2);
这仍然给我同样的警告。
为什么?我该如何解决?