Following example
public class C{
A myA;
public C(){
myA = new A();
}
}
public class A{
C myOrigin;
public A(){
// How to set myOrigin to the instance
// which invoke this.
}
}
Is there any way, to get the instance of class C, which creates the instance of A (inside this instance). With other words: Does an instance of A know the object from where it was initialised.
I know, I can use this as an parameter,
public class C{
A myA;
public C(){
myA = new A(this);
}
}
public class A{
C myOrigin;
public A(Object pObject){
myOrigin = pObject;
}
}
but I'm searching for a way without any parameter.