"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Every class is associated with "this" reference
Outer object would like this in memory
------- * this Outer Class
| id = |
| "STP" |
-------
Inner object would be like this in memory
----------- * this Inner Class
| id = |
| "default" |
-----------
So when the call is Outer.this.id it will call refer to the Outer class "this" and then call the id of the Outer class.
If you change the line OuterTest.this.id to InnerTest.this.id it will print "default"
[BOLD]
void doSomething ( ) {
System . out . println ( InnerTest . this . id) ;
}
[/BOLD]
Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.
"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Be YourSelf !!
Originally posted by Arshad Ahamed:
Please Explain the line InnerTest inner = outer.new InnerTest(); how this line initalize outerTest() constructor...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Be YourSelf !!
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|