This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes nested class extends 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 » Java » Java in General
Bookmark "nested class extends enclosing class" Watch "nested class extends enclosing class" New topic
Author

nested class extends enclosing class

Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
In this example, class A has 3 members, a field x, a method m and a nested class B. Since B extends A, B inherits the field x and the method m. x and m are members of B.
B is a member of A. Since B extends A, is B a member of B?
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
Since B extends A, is B a member of B?
yes. why is the confusion?
also, why one would need such functionality where "a member EXTENDS the container class"...
have you come across such an example?
regards
maulin
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
also,
run the following code to see what could go wrong if we mess up..

outcome? goes into infinite loop
regards
maulin
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Thank you Maulin for showing me how the code goes into an infinite loop. That is good to know.
I was have trouble trying to understand how a class declared in an interface could implement the interface. I think I made the problem worse by changing the interface to a class.
Thank you for your time. Marlene
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: nested class extends enclosing class