Reputation: 15
I have created a class called Gui
. It needs to extend JFrame
and another class called StudentDatabase
.
How can I do it ?
Upvotes: 0
Views: 367
Reputation: 572
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...
Upvotes: 2
Reputation: 23145
You can't. Java doesn't allow multiple inheritance. In C++ you can do this. In Java you can implement multiple "interfaces", but you'll have to rewrite the implementations of all functions in those interfaces in your class.
Upvotes: 0