Inheriting an abstract class vs implementing an interface

This question already has an answer here:

  • What is the difference between an interface and abstract class? 32 answers
  • Why to use Interfaces, Multiple Inheritance vs Interfaces, Benefits of Interfaces? 11 answers

  • 抽象类可以有非静态变量。


    There are some important differences between abstract class and interface. Some of them are listed below.

  • Abstract class can have implementation in it but interface can't.

  • In interface you can have only static final variable ( all the values declared in intrface is automatically constant and static Ie immutable variables ) but in abstract class you can have mutable variables.

  • Abstract class can be extended and only one abstract class can use for this but you can implement multiple interface in a class.

  • 链接地址: http://www.djcxy.com/p/54264.html

    上一篇: Java中的接口是什么?

    下一篇: 继承抽象类与实现接口