Originally posted by Tony Xu:
As I understand, the "this" refers to an instance of the class Inner since it is in the class Inner. Also, since used as OuterTest2.this, I think the "this" means something belong to OuterTest2.
Originally posted by Tony Xu:
My question is about the "this" in the marked line. What does it refer to?
As I understand, the "this" refers to an instance of the class Inner since it is in the class Inner. Also, since used as OuterTest2.this, I think the "this" means something belong to OuterTest2.
Anybody help and clarify for me? Thanks a lot.
Tony
SCJP2. Please Indent your code using UBB Code
Originally posted by galen wang:
more clearly,
when the flow is entered the run(), the 'this' instance included two class instances: Inner and Inner's outer OuterTest2. java uses the clas name as a prefix to distinguish these two instances.
so at this code position you can use OuterTest2.this to reference the instance of OutTest2 and you can also use Inner.this/this/(non frefix) to reference the instance of Inner.
Consider Paul's rocket mass heater. |