Summary:
Java programmers often use object polymorphism to make it easy to invoke appropriate methods in the right place, which is amazing. This approach is implemented through inheritance mechanisms. However, a rigorous experiment can make it clear and reveal that it is more appropriate to understand polymorphism as a type-related concept than to explain the inheritance mechanism. This understanding can help programmers to better use polymorphism.
------WM. Paul Roggs
The term "polymorphism" comes from Greek, meaning "multiple forms". Most Java programmers think of polymorphism as an object's ability to invoke the correct version of the method. Nevertheless, this perspective of implementation leads to the magical function of polymorphism, rather than simply thinking of polymorphism as a pure concept.
Polymorphism in Java is always polymorphism of subtypes. Almost mechanically produced some polymorphic behavior, so that we do not consider the types of problems involved. In this paper, we study a kind of object-oriented viewpoint, and analyze how to separate the behavior of the object and the behavior that the object will behave. Aside from the notion that polymorphism in Java is inherited, we can still feel that the interface in Java is a set of object sharing implementations that do not have common code.
Multi-State classification
Polymorphism is a common concept in object-oriented languages. Although we often confuse polymorphism, there are actually four different types of polymorphism. Before we begin the detailed discussion of the formal subtype polymorphism, let's look at the polymorphism in common object-oriented objects.
Luca Cardelli and Peter Wegner, author of the article "on understanding Types, Data abstraction, and polymorphism", Article reference resource link) divides polymorphism into two categories----specific and generic----four small categories: mandatory, overloaded, parametric and contained. Their structure is as follows:
In such a system, polymorphism shows many forms of ability. Generic polymorphic references have a large number of objects of the same structure type, and they share common characteristics. A particular polymorphism involves a small number of objects that do not have the same characteristics. The four polymorphic states can be described as follows:
Mandatory: A method of implicitly doing a type conversion.
Overloaded: Uses a marker as multiple meanings.
Parameters that provide the same action for different types of parameters.
Contains: An abstract operation in which a class contains a relationship.
I'll give you a brief introduction to these polymorphic forms before I tell you about subtype polymorphism.