What is recursive type bound
This: <T extends Comparable<T>>
Note that the type parameter T
is also part of the signature of the super interface Comparable<T>
.
and how does the above piece of code help achieve mutual comparability?
It ensures that you can only compare objects of type T
. Without the type bound, Comparable
compares any two Object
s. With the type bound, the compiler can ensure that only two objects of type T
are compared.