Let's say that I have the following class:
public class MyClass {
public void doSomething() {
System.out.println("doing something.");
}
}
Let's further assume, that all my project does is to call that .something()
method. No overriding or any other funny-business going on.
MyClass myObj = new MyClass();
myObj.doSomething();
Does the javac
compiler notice that this method call is not being overridden, and optimize the binding to "early binding"? I am asking out of curiosity; in any real-world application I would of course sprinkle final
, static
, and private
all over my code.