How can I access variable int a=89;
of Outer class inside my Inner class? Check my code. Help me to solve this.
public class TestOuter {
private String name = "Makky";
int a = 1;
public void dis() {
System.out.println("dis");
int a = 89;
class TestInner {
int a = 6;
void dis() {
int a = 12;
System.out.println("local inner class=" + a);
System.out.println("local inner class=" + this.a);
}
}
TestLocalInner ob = new TestLocalInner();
ob.dis();
}
private class TestInner {
int a = 2;
public void access() {
int a = 3;
System.out.println("a=" + a);
System.out.println("name=" + name);
System.out.println("a=" + this.a);
dis();
}
}
public static void main(String[] args) {
TestOuter.TestInner inner = new TestOuter().new TestInner();
inner.access();
TestOuter outer = new TestOuter();
System.out.println(outer.a);
}
}
Here I want to access variable int a = 89
of dis()
method in my Inner Class without print value of a=89
inside that dis method like System.out.println(a);
答案 0 :(得分:0)
TestInner
成员:this.a
TestInner.dis
本地变量:a
TestOuter
成员:TestOuter.a