-
Book Overview & Buying
-
Table Of Contents
Java 9 with JShell
By :
We can create instances of the PartyWithHearable<T, U> class by replacing both the T and U generic type parameters with any type names that conform to the constraints or the upper bounds specified in the declaration of the PartyWithHearable<T, U> class. We have three concrete classes that implement both the Sociable and Comparable<Sociable> interfaces required by the T generic type parameter: SocialLion, SocialParrot, and SocialSwan. We have two classes that implement the Hearable interface required by the U generic type parameter: Smartphone and AnimalMusicBand.
We can use SocialLion and Smartphone to create an instance of PartyWithHearable<SocialLion, Smartphone>, that is, a party of social lions and a smartphone. Then, we can use SocialParrot and AnimalMusicBand to create an instance of PartyWithHearable<SocialParrot, AnimalMusicBand>, that is, a party of social parrots and an animal music...