Java抽象类和接口
Java抽象类与接口以及它们的区别。
Abstract class
- Can have both abstract and concrete methods;
- A class can extend only one abstract class;
- Can have protected, public and public abstract methods;
- Can have static, final, or static final variables with any access modifier;
- "is-a" relationship;
- Cannot be instantiated;
Interface
- Can have only abstract methods;
- A class can implement multiple interfaces;
- Can have only public abstract methods;
- Can have only static final (constant) variables;
- "like-a" relationship;
- Can extend another interface;
参考资料
- Details on Difference between Java Abstract Class and Interface
- Difference Between Abstract Class and Interface in Java
- Abstract Classes and Methods in Java
- Interface in java with example programs