import java.util.ArrayList;
import java.util.List;
public class Gener{
private T tFiled;
public static void main(String[] args) {
List<? extends B> extended =new ArrayList<>();
B b = extended.get(0); //可取
//extended.add(new B()); 不可存 error: add(capture) in List cannot be applied to (B)
List<? super B> supered =new ArrayList<>();
supered.add(new B()); //B和B的子类都可存
Object x = supered.get(0); // 取出来只能时Object基类
}
}
class A {
}
class B extends A{
}
class C extends B{
}
class SomeClass{
}










网友评论