I am relatively new to the concept of generics in Java and I cannot tell the difference between the 2 answers.
The question at hand is :
Suppose we have a generic class E and we want the type parameter to E
to be a subClass of E
. In other words, we allow E<F>
only if class F
is either E
or inherits from E
.
I have narrowed down the options to what is possible.
1. class E<T extends E>
2. class E<T extends E<T>>.
I believe that option 1 meet the specification for the question. However i am confused about option 2, what does it actually extend.