Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

extending an inner class

 
lyko saha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic