Can one class extend two classes?
Java does not support multiple inheritance.
There are a few workarounds I can think of:
The first is aggregation: make a class that takes those two activities as fields.
The second is to use interfaces.
The third is to rethink your design: does it make sense for a Preferences
class to be both a PreferenceActivity
and an AbstractBillingActivity
?
Java doesn't support multiple inheritance. You can implement multiple interfaces, but not extend multiple classes.
Another solution is to create a private inner class that extends the second class. e.g a class that extends JMenuItem
and AbstractAction
:
public class MyClass extends JMenuItem { private class MyAction extends AbstractAction { // This class can access everything from its parent... }}