Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Extending Inner classes outside the enclosing class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Extending Inner classes outside the enclosing class" Watch "Extending Inner classes outside the enclosing class" New topic
Author

Extending Inner classes outside the enclosing class

Brian Lugo
Ranch Hand

Joined: Nov 10, 2000
Posts: 165
Any thoughts/comments on this ...

I am just slow today, so be patient with me
Brian
Jian Yi
Ranch Hand

Joined: Feb 01, 2002
Posts: 127
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

Joined: Jan 07, 2002
Posts: 2205
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.


Rob
SCJP 1.4
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
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 ]

<a href="http://www.rajindery.com" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Extending Inner classes outside the enclosing class