I extended two classes (TimerTask
and Jframe
) to my class but it shows me an error, is there any way to correct the error? I need them to set a timer in my GUI classes.
Asked
Active
Viewed 52 times
-1

Chrisvin Jem
- 3,940
- 1
- 8
- 24

Dhmia
- 1
- 1
-
Post the error that you get along with your code in the question. – Chrisvin Jem Jul 14 '19 at 11:01
-
2In Java, a class cannot extend two classes, but it can extend one and implement many interfaces. – devgianlu Jul 14 '19 at 11:01
-
Read this Q&A - https://stackoverflow.com/questions/21824402/java-multiple-inheritance – Stephen C Jul 14 '19 at 14:32
-
You should be able to set a timer in your `JFrame` subclass without making it a subclass of `TimerTask`. – Stephen C Jul 14 '19 at 14:35
1 Answers
0
Java does not support multiple inheritance. You cannot extend two class in Java. However, you can implement multiple interfaces but not extend multiple class. Try to rethink your design to handle it in a different way.

mithz
- 24
- 4