Summary
In this chapter, you learned to maximize code reuse by writing code capable of working with objects of different types, that is, instances of classes that implement specific interfaces or whose class hierarchies include specific superclasses. We worked with interfaces, generics, and constrained generic types.
We created classes capable of working with one constrained generic type. We combined class inheritance and interfaces to maximize the reusability of code. We could make classes work with many different types and we were able to code the behavior of a party that could then be reused to create parties of lions, parrots, and swans.
Now that you have learned the basics about parametric polymorphism and generics, we are ready to work with more advanced scenarios that maximize code reuse with generics in Java 9, which is the topic we are going to discuss in the next chapter.