Page 1 of 1

About Question enthuware.ocajp.i.v8.2.1360 :

Posted: Sun Oct 29, 2017 8:31 am
by Javier
Hi!
I understood that it is not possible to use this from a static context,
so why
i= this.i2; is legal? (i2 is static)

Thank you very much!!

Re: About Question enthuware.ocajp.i.v8.2.1360 :

Posted: Sun Oct 29, 2017 11:41 am
by admin
You have misunderstood the meaning the term "static context".
If you observe method1 closely, you will notice that it is an instance method. So the context in which this.i2 is present is not static. Therefore, "this" is available in this method and that is why this.i2 is valid.

Also remember that i2 is static and it is valid to access static members from static as well as non-static contexts.

Re: About Question enthuware.ocajp.i.v8.2.1360 :

Posted: Sun Oct 29, 2017 3:27 pm
by Javier
Thank you very much for the explanation Enthuware!
I got it now!