Java -- rewrite and reload, Java -- rewrite and reload

Source: Internet
Author: User

Java -- rewrite and reload, Java -- rewrite and reload

Overload:

First, it must be in the same class or derived class.

The function names must be the same.

The parameter list must be different. The parameter list includes the parameter type, number of parameters, and Parameter order.

The return value type can be the same or different.

1 public void func () {} 2 public int func (int a, int B) {return 0;} 3 public void func (int a, String B) {} 4 public void func (String B, int ){}

Rewrite:

It must occur in a derived class and is used to override the parent class method by subclass.

The function names must be the same.

The parameter list must be the same.

The return value must be the same.

The access permission is not lower than the parent class and is not private or static.

The overwritten parent class method cannot be final.

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.