Subclasses of generic types in Java -
when have example interface drivable
, class car
implements interface. if make class generic type garage<t extends drivable>
, possible make new garage<car>
or inheritance not work generic types , should garage<drivable>
?
the answer depends on types of drivable
want put garage
' if want able put type of drivable
garage
, declare garage<drivable>
. if ever want particular instance contain car
instances it's acceptable declare garage<car>
.
Comments
Post a Comment