In java, say I have the following class:
public class A{
protected class B{
}
}
can I extend the inner class by doing the following?
public class C extends A{
protected class D extends B{
}
}
What I want to do is that I have the class C above and I need to change something in A's inner class so I was thinking that I need to extend the inner class to do so but I wasn't sure how exactly to do that.
Any class. I'd say C is correct, because the group Any class or interface includes Object. The way I understand option B is "An inner class must extend the Object class.", and that would force us to extend all inner classes from Object.
It can be accessed without instantiating the outer class, using other static members. Just like static members, a static nested class does not have access to the instance variables and methods of the outer class. You can extend static inner class with another inner class.
Local inner classes can extend an abstract class or implement an interface.
According to this page, you have the right way figured out to extend inner classes. A few tips about it can be found here, in the middle of the article (search for "extend").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With