Page 1 of 1

About Question enthuware.ocpjp.v7.2.1550 :

Posted: Thu Sep 15, 2016 4:44 am
by Paulus
The 2nd answer states:

Code: Select all

As there is no conflict, the compiler figures out that 'i' is actually Outer.this.i.
Could you give an example of what is ment by a conflict in this case?

Re: About Question enthuware.ocpjp.v7.2.1550 :

Posted: Thu Sep 15, 2016 9:24 am
by admin
You could have a local variable i in the method or even in the class Inner as well.
ie.

Code: Select all

public class Outer
{
  int i = 10;
  class Inner
  {
    int i = 20;
    public void methodA()
    {
       i = 30;
       //line 1.
    }
  }
}