wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes extending an inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "extending an inner class" Watch "extending an inner class" New topic
Author

extending an inner class

lyko saha
Greenhorn

Joined: Aug 21, 2004
Posts: 5
Is it possible to extend a non-static inner class outside of its outer class? For example:

class Outer
{class Inner {}
}
public class A extends Outer.Inner
{}

If I compile class A, I get an error:
No enclosing instance of class B is in scope; cannot create a default constructor for class A.
Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815
I would say that regardless of whether it is possible or not, which I truly don't know the answer to, you should never need to. The point of an non-static inner class is that it belogs within the outer class. Period. If you want to make an extension of the outer class that has an inner class that extends the inner class of the super class, this is perfectly doable, however convoluted.

dig?


I've heard it takes forever to grow a woman from the ground
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
No.


Tony Morris
Java Q&A (FAQ, Trivia)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: extending an inner class
 
Similar Threads
Inner Class - Initialization Sequence
confused question
static inner class instantiation
use of Outer.this
Inner Class