Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parameter with question mark and super [duplicate]

Tags:

java

In Java, I've come across a method that is formatted like this:

public final Subscription subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError) {
}

In the first parameter, what does the question mark and super mean?

like image 668
Johann Avatar asked Oct 22 '25 15:10

Johann


1 Answers

? here means everything that is a superclass of T

super means what you can put into the class (at most this, perhaps a superclass).

Because super indicates the lower bounding class of a generic element. So, Action1<? super T> could represent Action1<T> or Action1<Object>.

like image 72
Bahramdun Adil Avatar answered Oct 25 '25 15:10

Bahramdun Adil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!