Java中的绑定-术语 [英] What is binding in Java - Terminology

查看:39
本文介绍了Java中的绑定-术语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道什么是静态绑定和动态绑定.所以我的问题与此无关.

I know what is static binding and dynamic binding. So my question is not related to this.

根据:

1)Java中的静态绑定发生在编译期间,而动态时发生绑定在运行时发生.

1) Static binding in Java occurs during Compile time while Dynamic binding occurs during Runtime.

2)私有方法,最终方法和静态方法以及变量使用静态绑定并由编译器绑定,而虚拟方法是在运行时根据运行时对象进行绑定.

2) private methods, final methods and static methods and variables uses static binding and bonded by compiler while virtual methods are bonded during runtime based upon runtime object.

3)静态绑定使用Type(Java中的Class)信息进行绑定而动态绑定使用对象来解析绑定.

3) Static binding uses Type(Class in Java) information for binding while Dynamic binding uses Object to resolve binding.

3)重载的方法在覆盖时使用静态绑定进行绑定在运行时使用动态绑定来绑定方法.

3) Overloaded methods are bonded using static binding while overridden methods are bonded using dynamic binding at runtime.

让我们专注于上述方面:

Let's focus on one aspect of above :

现在,我们看到静态绑定将类和实例变量绑定到它们的值,并将静态方法调用绑定到相关方法主体.

Now we see that static binding binds class and instance variables to their values and static method calls to relevant method body.

但是在诸如 this 的某些地方,它们定义了绑定

But at some places like this , they define binding as

将方法调用与方法主体的关联称为绑定.

Association of method call to the method body is known as binding.

但是绑定也可以绑定变量.

But binding also binds variables too.

现在我很困惑.绑定是否还与对方法主体的方法调用或与变量的值相关?我们如何定义绑定?

Now I am confused. Is binding related to just method calls to method body or variables to their values too ? How do we define binding ?

推荐答案

通常,绑定"是将标识符与它所标识的内容(方法,变量或类型)相关联.

Most generally, "binding" is about associating an identifier to whatever it identifies, be it a method, a variable, or a type.

Java中的所有绑定都是静态的(早期"),实例方法的绑定可能是静态的也可以是动态的(后期"),具体取决于方法的可访问性.

All bindings in Java are static ("early") except for bindings of instance methods, which may be static or dynamic ("late"), depending on method's accessibility.

Java语言规范提到了上下文中的绑定访问字段以及在访问实例方法的上下文中.第15.11章比较了字段绑定(静态)和实例方法绑定(动态),并提供了对比两种绑定的代码示例.

Java Language Specification mentions binding both in the context of accessing fields and in the context of accessing instance methods. Chapter 15.11 compares field binding (static) vs. instance method binding (dynamic), and provides code examples to contrast the two kinds of binding.

这篇关于Java中的绑定-术语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆