How can I access this m1() method in the following program?
问题 How can i access the x = 15 value from m2() ? I am accessing following values as given in comment of the program. class A { int x = 10; void m1(){ int x = 15; //How can we access x =15 ? class B{ int x =20; void m2(){ int x = 25; System.out.println(x); //for x = 25 System.out.println(this.x); //for x = 20 System.out.println(A.this.x); //for x = 10 System.out.println(); } } } } 回答1: Actually, you can't get access to x defined in m1() . To fix it, you could change the variable name: void m1() {