Java access the caller variable, is it possible? how?

Posted by lacas on Stack Overflow See other posts from Stack Overflow or by lacas
Published on 2011-11-25T17:43:45Z Indexed on 2011/11/25 17:50 UTC
Read the original article Hit count: 155

Filed under:

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?

© Stack Overflow or respective owner

Related posts about java