Binding Technology (continued)

Source: Internet
Author: User
The so-called "binding )": Is to establish the association between method call (function call) and method body (function body. If the binding occurs on Program Before running, it is called "Early binding". There is no other choice for procedural language. Only one method is to bind the binding action in advance. During the program execution period, the binding action is performed based on the object type, it is called "late binding" or "run-time binding" or "dynamic binding )".
All functions of Java, except those declared as final functions, are bound later. Later binding will automatically take place.
Final is used to prohibit overridding the function, and tells the compiler that the function does not need to be bound later, so that the program can achieve better performance, but in fact, this will not improve the overall efficiency of the program.

Example:   Class A {
Public   Void Play () {
System.Out. Println ("IsRunning. ");
}

Class B extends {
Public   Void Play () {
System.Out. Println ("B"IsRunning. ");
}

Class C extends {
Public   Void Play () {
System.Out. Println ("CIsRunning. ");
}

Public   Class Testlatebinding {
Static   Void Play () {
A. Play ();
}
Public   Static   Void Main (string [] ARGs) {
Play (NewA ());
Play (NewB ());//Late binding
Play (NewC ());//Late binding
}
}

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.