I have seen this question in javaworld forum (http://forums.devworld.com/webx?14@120.MfiwaiOLnYP^84875@.ee6b80a/1701
). There are no response to this. I am very much intrested to know the answer for this.
How can I reference the class of the object that invoked a method in another class?
For example, I have the class: com.foo.stuff.PrimaryClass
It has an instance variable of type com.foo.util.WorkerClass
As some point, PrimaryClass invokes the method: workerClass.doSomething(someString);
Inside the workerClass.doSomething method, I need to invoke the getClass method on the calling Object (PrimaryClass in this case)
So inside WorkerClass I would have something like:
public void doSomething(String name)
����Object callingObject = ???;
����Class c = callingObject.getClass();
What is the ???
Thanks in advance!