- producer-extends
- consumer-super
public class Example {
public static void main(String[] args) {
// 父 - 子
// A -> B -> C -> D -> E
// consumer(Collection<? super C> data)
producer(Lists.<A>newArrayList());
producer(Lists.<B>newArrayList());
producer(Lists.<C>newArrayList());
// producer(Collection<? extends C> data)
consumer(Lists.<C>newArrayList());
consumer(Lists.<D>newArrayList());
consumer(Lists.<E>newArrayList());
}
public static void consumer(Collection<? super C> data) {
// 可写不可读
}
public static void producer(Collection<? extends C> data) {
// 可读不可写
}
}