Java code:
class Animal {}
class Cat extends Animal {}
class Box<T> {}
public class Test {
public void hello(Box<? extends Animal> box) {}
}
Box<Animal> box1 = new Box<Animal>();
Box<Cat> box2 = new Box<Cat>();
new Test().hello(box1);
new Test().hello(box2);
From Liskov Substitution Principle, since box2
with type Box<Cat>
can be used where it requires a type Box<? extends Animal>
, can I say:
Box<Cat> is subtype of Box<? extends Animal>
Actually: I'm not even sure if Box<? extends Animal>
and ? extends Animal
are types