Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
462 views
in Technique[技术] by (71.8m points)

java 泛型设计的疑问

 public final i a(final rx.c.b<? super T> bVar, final rx.c.b<Throwable> bVar2) {
        if (bVar == null) {
            throw new IllegalArgumentException("onNext can not be null");
        } else if (bVar2 != null) {
            return b((h<? super T>) new h<T>() {
                public final void onCompleted() {
                }

                public final void onError(Throwable th) {
                    bVar2.call(th);
                }

                public final void onNext(T t) {
                    bVar.call(t);
                }
            });
        } else {
            throw new IllegalArgumentException("onError can not be null");
        }
    }

final rx.c.b<? super T> bVar 这里为啥有个"?" ?代表不确定的,这里我的理解是 rx.c.b 下面的 一个是T 这个子类的一种类型?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

? extend T:上界通配符,可以认为限定某个类(?)必须是T类型类的子类型
? super T:下界通配符


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...