• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on inner classes

 
shuba gopal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The output printed is "middle". I understand why "inner" will not be printed. Why isnt "outer" printed?
 
Piyush Joshi
Ranch Hand
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
shuba gopal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piyush, thanks and Welcome to the ranch
 
shuba gopal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The way size variable is used is an example of shadowing. Am I right?
 
Piyush Joshi
Ranch Hand
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes somewhat like that.

More elaborately:


 
shuba gopal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Piyush
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic