Java4android Basic Learning Replication (override)

Source: Internet
Author: User

1. Replication (override)

1) exists with the parent class and subclass;

2) Each of the parent and child classes has a function, the two function names, the return value type, the parameter list, exactly the same, which is called the relationship between the two functions as a replication (override);

// Parent Class class father{    void function () {        System.out.println ("Function of the parent class");}  }   
// sub-class class extends father{    void function () {      System.out.println ("function of the subclass");}    }

This means that there is a replication relationship between the function functions in Son and father.

2. Call the member function in the parent class with super;

1) use Super.function () to invoke functions in the parent class, such as:

// Parent Class class father{    void function () {        System.out.println ("Function of the parent class");}  }        
// sub-class class extends father{    void  function () {
super.function (); System.out.println ("function of the subclass");} }

  

Java4android Basic Learning Replication (override)

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.