After class, try to move your brain.

Source: Internet
Author: User

This hands-on brain is about the use of overloading in Java methods, and the use of overloading in programming is extensive. The overloads in Java and others are somewhat different, and the three conditions that can make up an overload are: 1. In the same class. 2. The method name must be a phase. 3. The method has different parameter classes. The most important point is that the return value of the method is not judged by the method overload. This three point is the emphasis that makes up the overload. Many of us are often prone to use the return value of a method as a condition of judgment and therefore make a mistake. When overloaded, the method name is the same, but the parameter type and number are different, and the return value type can be the same or different. Java's method overloading is that you can 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.

The cases that cannot be overloaded are: 1. For two methods, if only the return value is different, the program will error if it does not constitute an overload. 2. For two methods, if only the access modifiers are different, the program will error if it does not constitute an overload. 3. For two methods, if only the parameter name is different, then does not constitute an overload, the program will error. Overloading is concerned with parameters, parameters, parameter types, different parameters, different types of parameter order, can implement the method of overloading.

After class, try to move your brain.

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.