As one of the three major features of Java, Polymorphism is an important feature that many people have not figured out, and today I come from the perspective I understand.
First of all, from his literal meaning to understand, polymorphic, from its literal understanding is a variety of forms, multiple manifestations. According to these, I most can think of the example is the graph, the graph is a very big class, he contains the triangle, the rectangle, the circle, the trapezoid, the Pentagon and so on, but they all belong to the graph class, the expression form each has the characteristic, the property, the method are different. So, the 1th thing I understand is that polymorphism refers to the different representations of subclasses relative to the parent class (including the subclasses ' rewriting of the parent class method, which is an important embodiment of polymorphism).
Another point, I see in the book "Thinking in JAVA", that is, the class constructor can have many forms, we can choose the appropriate construction method according to our own needs, the following example:
PackageCreatorthis; Public classcallcreatorbythis {callcreatorbythis () {//Constructor 1PRT ("I'm a parameterless constructor ..."); } callcreatorbythis (String text) {//Constructor 2prt (text); } callcreatorbythis (String text,inti) {//Constructor 3 This("hahaha, I am the Test text ... I called the other constructor "+text); I=+i; } voidprt (String text) {System.out.println (text); } Public Static voidMain (String args[]) {Callcreatorbythis Creator=NewCallcreatorbythis (); }}
Language organization is a bit confusing, the expression is also more superficial, welcome to spit Groove and add, after all, I am a rookie!
Three major features of Java--polymorphism