Java Method Overloading Learning notes

Source: Internet
Author: User

Overloading of methods in Java

(1) method overloading is a means of allowing classes to handle different types of data in a uniform manner. Multiple functions with the same name exist at the same time, with different number/types of parameters.

Overloaded overloading is a representation of polymorphism in a class.

(2) Java's method overloading is the ability to create multiple methods in a class that have the same name but have different parameters and different definitions.

The method is called polymorphism by the number of different arguments passed to them and by the type of parameter to determine which method to use.

(3) When overloading, the method name is the same, but the parameter type and number are different, the return value type can be the same or different. The return type cannot be used as a distinguishing criterion for overloaded functions.

Rules for method overloading:

1, must have a different list of parameters;

2, can have a different return type, as long as the parameter list is different can be;

3, can have different access modifiers;

4, can throw different anomalies;

Java Method Overloading Learning notes

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.