如果我有以下情况:
class A {
public A() { }
public static void foo() { System.out.println("foo() called"); }
}
public class Main {
public static void main(String [] args) {
A a = new A();
a.foo(); // <-- static call using an instance.
A.foo(); // <-- static call using class
}
}
使用实例调用 foo() 可能会出现任何问题吗?JVM 是否将第一次调用 foo() 完全视为静态方法,还是有一些技术上的微妙之处?