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!!
About Question enthuware.ocajp.i.v8.2.1360 :
Moderator: admin
-
- Posts: 66
- Joined: Mon Feb 20, 2017 12:31 pm
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1360 :
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.
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.
-
- Posts: 66
- Joined: Mon Feb 20, 2017 12:31 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1360 :
Thank you very much for the explanation Enthuware!
I got it now!
I got it now!
Who is online
Users browsing this forum: No registered users and 17 guests