Java method Call Binding

Source: Internet
Author: User

Associating a method call with the same method body is called a binding. Binding (implemented by compilers and connectors) prior to program execution is called early binding . The reader may never have heard of the term because it does not need to choose the default binding method in a process-oriented language. For example, the C language has a method call, that is, early binding. late binding is also called dynamic binding or run-time binding , meaning that it is bound at run time based on the type of the object. If a language wants to implement late binding, it must have a mechanism that can determine the type of the object at run time and thus invoke the appropriate method. That is, the compiler never knows the type of the object, but the method invocation mechanism can find the correct method body and call it. Late binding mechanisms vary from one programming language to another, but if you think about it you'll know that somehow you have to place some kind of "type information" in the object.

In addition to the static method and the final method in Java (the private method belongs to the final method), the other methods are late-bound. This means that in general, we don't have to decide whether late binding should happen, because it happens automatically. Sometimes, a method is declared final and can be used to prevent others from overwriting the method. But perhaps the more important point is that doing so effectively turns off late binding, or tells the compiler that it does not require dynamic binding. This allows the compiler to generate more efficient code for the final method call. However, in most cases, this does not improve the performance of the program. Therefore, it is best to decide whether to use final based on the design, rather than using final for the purpose of trying to raise performance.

Java method Call Binding

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.