Can a class have two superclasses at the same time?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpuser123
    New Member
    • Dec 2009
    • 108

    Can a class have two superclasses at the same time?

    I have a class Journey which I want to make a superclass and another class plannedjourney.
    The plannedjourney class extends JFrame since it contains forms..However I also want this class to extends Journey..

    Is there a possible way to do this?
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    You can use interfaces.

    Regards
    Dheeraj Joshi

    Comment

    • Dheeraj Joshi
      Recognized Expert Top Contributor
      • Jul 2009
      • 1129

      #3
      Or you can also use inner classes. I guess if you do not want interfaces better to use inner classes.

      Regards
      Dheeraj Joshi

      Comment

      • horace1
        Recognized Expert Top Contributor
        • Nov 2006
        • 1510

        #4
        See the following discussion "Why not multiple inheritance?" in Javaworld
        Business technology, IT news, product reviews and enterprise IT strategies.

        Comment

        Working...