| SE450: Types: Subtyping [28/47] | ![]() ![]() ![]() |
Objects may inhabit more than one type.
Object x = new Integer(1);
If all of the objects in D are also in
B, we say:
D is a subtype of BThis is called subtype polymorphism.
Common notation for theorists:
.
D <:
B
Subtype related to subset -- values(D)
is a subset of values(B)
Integer is a subtype of Object.
Integer is a subtype of Comparable.