Search code examples
jframeextend

How can I extend 2 classes in Java? I need to extend JFrame plus another class


I have created a class called Gui. It needs to extend JFrame and another class called StudentDatabase.

How can I do it ?


Solution

  • You can't extend more than one class in Java.

    Instead of using inheritance use composition (extend JFrame and have a member of class StudentDatabase in your class GUI).

    Pass invocations of methods in GUI to its member StudentDatabase and voila...