Originally posted by Sanjeev Kumar Singh:
The inner class can not reached with out a outer class so inner class can not be inherited,If I am not wrong.However a static inner class can be inherited like
It is invalid to inherit the Inner class by its enclosing outer class.
The above code is invalid.
hi Sanjeev,
you are in big confusion as you said ,"inner class can not be inherited". we can extend Inner classes as well.please try the code below.
class Outer{
class Inner{
}
}
class OuterDemo{
class InnerDemo ectends Outer.Inner{
public InnerDemo(){
Outer.super();
}
}
}
as InnerDemo class does not no which object to bind to so the non-default
constructor is necessary to intimate Outer class that it has an outer
object to bind to.
However this outer object problem is not arised if OuterDemo ectends Outer
class.in that case we need not use non-default constructor.
hope this will help
.
if still confused please let me know.
Regards.
MAneesh Saxena