Forums Register Login

How do I extend an abstract inner class

+Pie Number of slices to send: Send
Hello Guys,
If I have an abstact/non-abstract class and an abstract inner class, How can I extend this inner class?

Does it make any sense in real world to make an inner class abstract??

Thanks!

[ August 23, 2007: Message edited by: Muni K Reddy ]
[ August 23, 2007: Message edited by: Muni K Reddy ]
+Pie Number of slices to send: Send
I'm not sure what "an abstact/non-abstract class" is, but have you tried using an abstract nested class? It works very much like a top-level abstract class.
+Pie Number of slices to send: Send
 

Does it make any sense in real world to make an inner class abstract??

Absolutely. If your class requires the use of a number of other classes that are related to each other (ie form a class hierarchy) and those classes are particular to the parent class (ie are ideal candidates for implementation as inner classes) then it is probable that the super class of the inner class hierarchy will be abstract.
+Pie Number of slices to send: Send
 

Originally posted by marc weber:
I'm not sure what "an abstact/non-abstract class" is, but have you tried using an abstract nested class? It works very much like a top-level abstract class.



Mark, I meant abstract or a non abstract top level class but specifically having a nested abstract inner class .
  • How do I extend this abstract inner class?
  • Is it of any value if I make the nested inner class abstract?
  • +Pie Number of slices to send: Send
     

    Absolutely. If your class requires the use of a number of other classes that are related to each other (ie form a class hierarchy) and those classes are particular to the parent class (ie are ideal candidates for implementation as inner classes) then it is probable that the super class of the inner class hierarchy will be abstract.



    Tony, I meant marking the nested inner class abstract, not the outer class! Does it make sense?
    +Pie Number of slices to send: Send
     

    Originally posted by Muni K Reddy:
    ...

  • How do I extend this abstract inner class?
  • Is it of any value if I make the nested inner class abstract?
  • Tony's explanation applies to abstract classes in general, whether they are top-level or nested. It's the same idea, just in the context of an enclosing class.

    As for how to extend an abstract nested class... It's the same as extending a concrete nested class, except that you need to implement any abstract methods (just as you would if you were extending a top-level abstract class).

    The best way to learn about this is to try writing some code.
    +Pie Number of slices to send: Send
     


    Tony's explanation applies to abstract classes in general, whether they are top-level or nested. It's the same idea, just in the context of an enclosing class.

    As for how to extend an abstract nested class... It's the same as extending a concrete nested class, except that you need to implement any abstract methods (just as you would if you were extending a top-level abstract class).

    The best way to learn about this is to try writing some code.



    Mark, After a bit of fighting I did this.


    When I had posted the question I tried to do something like this:

    Does this imply that the outer class needs to be extended before any of the inner classes can be extended ?. I guess it does not make sense to directly inherit an inner class.
    +Pie Number of slices to send: Send
     

    Originally posted by Muni K Reddy:
    ... Does this imply that the outer class needs to be extended before any of the inner classes can be extended ? ...


    Not necessarily, because you can extend a nested class within the same enclosing class. For example...

    Also note that in your code, A1 extends Test, so A1 inherits the nested class TestINNER. Therefore, you can just say "A2 extends TestINNER" instead of "A2 extends Test.TestINNER."

    Here are some other things you can do...
    +Pie Number of slices to send: Send
    Thanks Marc! That clears a few doubts!
    [ August 24, 2007: Message edited by: Muni K Reddy ]
    I don't like that guy. The tiny ad agrees with me.
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 16496 times.
    Similar Threads
    URL Rewriting .. jsessionID appears only once in the session!
    Incentive to non- sheriff's and non-moderators
    hashCode() static reference from abstact class
    EL -is it being used?
    use of a page implicit object
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 28, 2024 22:54:56.