0

This question is for Java

Here is an example:

     public class A {

        int thing = 1;

          public class B {

             int thing = 2;
             System.out.println("I want to print out thing from class A" +what goes here?);
          }
     }   
MyNameIsNemo
  • 71
  • 1
  • 2
  • 9

3 Answers3

0

You qualify the variable with the class name and this :

System.out.println("I want to print out thing from class A" + A.this.thing);
Eran
  • 387,369
  • 54
  • 702
  • 768
0

use A.this.thing for "what goes here?"

Ramanlfc
  • 8,283
  • 1
  • 18
  • 24
0

you can access A's variable as A.this.thing

Imrank
  • 1,009
  • 5
  • 15