我不明白为什么下面的代码会产生警告。Java:泛型下拉会生成警告,为什么?
interface Generic<T> {
}
interface A {
}
class B {
Generic<A> c;
<T extends A> B(Generic<T> a) {
c = (Generic<A>) a; //warning here
}
}
//Unchecked cast from Generic<T> to Generic<A>
在B类我只是在使用的类型为A.一般的情况下,该警告表明,我需要的通用参数存储为一件T而非A.
感兴趣,但是这意味着我将不得不声明B通用,这似乎使事情变得比他们需要的更复杂。
当你不施放时会发生什么? – aperkins 2009-09-07 21:49:47
类型不匹配错误 – Mike 2009-09-07 21:50:17