Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extending Inner classes outside the enclosing class

 
Brian Lugo
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any thoughts/comments on this ...

I am just slow today, so be patient with me
Brian
 
Jian Yi
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't it the same that we can refer to the static member of a class using Class.variable while we can't do that to the non-static members?
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My thoughts are, this is interesting. I hadn't thought about this before, but it makes sense to me.
An inner class has no independant existance apart from an actual instance of the outer class. That's why you can't declare static members in an inner class. Think about it. If you can't use static members, then for the same reason, you can't extend inner the class outside the outer class.
 
Rajinder Yadav
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class Inner2 is not visiable outside of class OuterfromInner1 because of scoping rule, since class Inner2 is not declared static you can only extend this class within class Outer2
[ February 20, 2002: Message edited by: Rajinder Yadav ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic