Three major features of Java--polymorphism

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.