suppose we have
class Fruit implements Comparable<Fruit>
{
@Override
public int compareTo(Fruit o) { return 0; }
}
class Apple extends Fruit{}
class Main
{
public static void main (String args[])
{
function(new Apple()); // this shouldn't work because Apple is implementing Comparable<Fruit>, not Comparable<Apple>
}
public static<T extends Comparable<T>> void function(T t){}
}
Code is working without any issue.
My question is why <T extends Comparable<T>>
working like <T extends Comparable<? super T>>
. whats the difference ?
Thanks.
[Edited] - A passage from book Image