Java access the caller variable, is it possible? how?
- by lacas
i have a class
main {
Class1 class1=new Class1();
class1.function1();
}
class Class1 {
int abc=1;
ArrayList<Class2> class2s=new ArrayList<Class2>();
int function1() {
class2s.add(new Class2(asd));
abc=555;
}
}
class Class2 {
int functionx() {
Log.e("abc?", ""+PARENT???.abc);
}
}
How can I get the caller Class's variable, say abc?