This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Question on inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question on inner classes" Watch "Question on inner classes" New topic
Author

Question on inner classes

shuba gopal
Ranch Hand

Joined: May 12, 2011
Posts: 76


The output printed is "middle". I understand why "inner" will not be printed. Why isnt "outer" printed?
Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

Hi

Outer will not be printed because Inner Class A will shadow the outer Class A.

This shadowing is similar to shadowing of the instance variables by local variables with same names.


Piyush
shuba gopal
Ranch Hand

Joined: May 12, 2011
Posts: 76
Piyush, thanks and Welcome to the ranch
shuba gopal
Ranch Hand

Joined: May 12, 2011
Posts: 76


The way size variable is used is an example of shadowing. Am I right?
Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

Yes somewhat like that.

More elaborately:


shuba gopal
Ranch Hand

Joined: May 12, 2011
Posts: 76
Thanks Piyush
 
Consider Paul's rocket mass heater.
 
subject: Question on inner classes
 
Similar Threads
Question related to inner class
Question on Inner classes
Inner classes
inner class question
inner class doubt