Home  >  Article  >  Java  >  How to implement static binding in java

How to implement static binding in java

WBOY
WBOYforward
2023-04-30 22:22:05702browse

Concept

1. Static binding is also called early binding and compile-time binding.

2. The method has been bound before the program is executed (that is to say, during the compilation process, it is already known which class the method is in), which is implemented by the compiler or other linker.

3. Among the methods in Java, only final, static, private modified methods and constructors are statically bound.

Example

//被调用的类
package hr.test;
class Father{
      public static void f1(){
              System.out.println("Father— f1()");
      }
}
//调用静态方法
import hr.test.Father;
public class StaticCall{
       public static void main(){
            Father.f1(); //调用静态方法
       }
}

The above is the detailed content of How to implement static binding in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete