Reputation: 3281
what does this exactly mean?
public class Deck<T extends Card>
What does the T extends Card mean? Does this imply something about the class Card?
thanks!
Upvotes: 3
Views: 279
Reputation: 1642
It constrains the type parameter ("T") to be Card
or a subtype of Card
.
So if
public class FancyCard extends Card
... then it is a valid type for use with Deck
(i.e. Deck<FancyCard>
). However, String
obviously does not extend Card
, so Deck<String>
will not compile.
Upvotes: 6