Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java invoker

Name: Anonymous 2012-12-01 19:13

In Java, is it possible to get the invoker of a class? I am trying to create two classes simultaneously but I want them to reference each other, preferably upon creation(constructors) if possible. I know I can sort of do it by returning the stack trace, but this doesn't exactly seem... proper. Any ideas /prog/?

Name: Anonymous 2012-12-01 19:25

Class1 {
   Class2 class2;
   public Class1(Class2 class2) {
      this.class2 = class2;
   }
   public static void main(String[] args) {
       Class1 class1 = new Class1(new Class2());
       //reference of class 2 from class 1 is complete.
       //but how can i reference the vice versa as well, so
         both objects reference each other?
   }
}

Class2 {
   public Class2() {
   }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List