gpt4 book ai didi

java - 为什么 `invokespecial`用于调用java中的 ``方法?

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:29:51 27 4
gpt4 key购买 nike

为什么是invokespecial用于调用 <init> Java 中的方法?

我看了很多地方,但无法理解完美的原因?

如有任何帮助,我们将不胜感激。

最佳答案

来自 here :

The main use of invokespecial is to invoke an object's instance initialization method, <init>, during the construction phase for a new object.

同样来自 here :

In other words, invokespecial is used to call methods without concern for dynamic binding, in order to invoke the particular class’ version of a method.

第二个引用最适用您的问题,因为我们知道调用构造函数 ( <init> ) 方法始终具有静态绑定(bind)。

关于java - 为什么 `invokespecial`用于调用java中的 `<init>`方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13721111/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com