jeudi 30 juillet 2015

Get instance of class from which was method called

i need to get instance of class from where was method called. If it is possible. Example:

class Class1{
String n = "1";
  Class1{
    new Class2.someMethod();
  }
}
class Class2{
  void someMethod(){
  //Class1 cl = (Get instance of Class1);
  //System.out.println(cl.n);
  }
}

So output will be "1"





Aucun commentaire:

Enregistrer un commentaire