抽象类与接口比较 抽象类跟接口类似,都不能实例化,可能包含不需实现方法或已实现的方法. 抽象类可以定义一些不是静态或常量的字段,定义 public, protected, private访问级别的具体方法. 接口的所有字段自动是public.静态.常量,所有定义的方法的访问级别都是public. 类只能继承一个抽象类,可以实现多个接口. 抽象类使用场景 1.你想在几个密切相关的类共享代码. 2.你想让继承你抽象类的类有一些共用的字段或方法,或想设置protected, private的访问级别.…