class Test extend Test1
class Test implements Test1
Does anyone have a detailed demo to explain the difference between extend and implements? I don’t understand the online examples in detail.
青Blue2020-06-15 22:08:39
One is to inherit the parent class. The subclass can only implement some methods in the parent class. The parent class can contain member methods (that is, the function has a function body). A subclass can only inherit one parent class.
The other is to implement an interface. A class can implement multiple interfaces at the same time and inherit a parent class at the same time. During the implementation process, all methods in the interface must be implemented. The interface can only have method names, not Method content (only function name, no function body).
Probably like this