Suppose that I have a Java class with a static method, like so:
class A { static void foo() { // Which class invoked me? } }
And suppose further that class A has an arbitrary number of subclasses:
class B extends A { } class C extends A { } class D extends A { } ...
Now consider the following method invocations:
A.foo(); B.foo(); C.foo(); D.foo(); ...
My question is, how can method foo()
tell which class is invoking it?