What is polymorphic
The benefits of polymorphism
For example: Demand: A way for breeders to feed animals to feed animals
If there is no polymorphism, we will find that for different types of animals, we need to provide different feed methods to feed, when the demand changes, such as increasing the animals, it is necessary to increase the animal's feed, the code is not concise and elegant.
I just wanted to provide a feeding method to feed all types of animals, and to unify feeding behavior, it is time to introduce polymorphism, requiring only one feeding method to respond to changing needs.
Therefore, the role of polymorphism is to treat different sub-object as a parent, you can block different sub-class object implementation differences, the use of common code to adapt to the changing needs, to achieve universal programming.
Java Learning Note (18): polymorphic