When to implement an interface and when to extend a superclass?
问题 I\'ve been reading a lot about interfaces and class inheritance in Java, and I know how to do both and I think I have a good feel for both. But it seems that nobody ever really compares the two side by side and explains when and why you would want to use one or the other. I have not found a lot of times when implementing an interface would be a better system than extending a superclass. So when do you implement an interface and when do you extend a superclass? 回答1: Use an interface if you