Implement an interface and override methods in Java?

后端 未结 6 969
旧巷少年郎
旧巷少年郎 2021-01-24 16:14

Why do you have to override all methods of an interface?

For instance if I have

public class Foo extend JFrame implements ActionListener, KeyListener {
          


        
6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-24 16:44

    Interfaces have no default implementation. If you weren't forced to implement each method in the interface, then what would happen when some other code tries to call these methods through the interface?

提交回复
热议问题