inner class extending

user1082160 picture user1082160 · Feb 27, 2012 · Viewed 19.4k times · Source

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.

Answer

malexmave picture malexmave · Feb 27, 2012

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").