abstract和interface class

使用abstract class的方式定义Demo抽象类的方式如下:  

abstract class Demo {  
 abstract void method1();  
 abstract void method2();  
 …  
}  

使用interface的方式定义Demo抽象类的方式如下:  

interface Demo {  
 void method1();  
 void method2();  
 …  
}  

在abstract class方式中,Demo可以有自己的数据成员,也可以有非abstarct的成员方法,而在interface方式的实现中,Demo只能够有静态的不能被修改的数据成员(也就是必须是static final的,不过在interface中一般不定义数据成员),所有的成员方法都是abstract的。从某种意义上说,interface是一种特殊形式的abstract class。  

原文地址:https://www.cnblogs.com/liuyuanyuanGOGO/p/2970604.html