Java中的静态方法是否始终在编译时解决? [英] Are static methods in Java always resolved at compile time?
本文介绍了Java中的静态方法是否始终在编译时解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Java中的静态方法是否总是在编译时解决?
Are static methods in Java always resolved at compile time?
推荐答案
几个引号:
当编译器编译该类时,它在编译时决定为每个静态方法调用调用哪个确切的方法(这与非静态方法调用有很大区别:要调用的确切方法仅由在那些情况下在运行时)。
"When the compiler compiles that class it decides at compile time which exact method is called for each static method call (that's the big difference to non-static method calls: the exact method to be called is only decided at runtime in those cases)."
只调用静态方法取决于调用它的编译时类型。
"Calling static methods only ever depends on the compile-time type on which it is called."
这篇关于Java中的静态方法是否始终在编译时解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文