Abstract class: Keyword: abstract
1、包含抽象方法的类 叫做抽象类 abstract
2、抽象类 不能被实例化 new
3、抽象类当中可以有抽象方法 也可以有非抽象方法或者成员变量
4、抽象类 就是为了继承的
5、抽象类被 继承之后 一定要重写抽象方法
6、抽象类A如果继承了抽象类B,那么抽象类A可以选择重写或者 不重写抽象类B当中的方法。
7. 抽象类不能是private
interface:
1.关键字:interface
2.接口当中的方法全部不能有具体的实现:
接口当中的方法都是抽象方法---默认的public abstracta
3.阿里巴巴:接口当中的方法尽量简洁
4.接口当中的成员变量默认是public static final
5.接口不能被实例化的new
6.接口存在的最大意义就是为了被继承
7.向上转型:IShape IShape=new Rect();
IShape IShape=new Cycle();
8.接口可以实现多继承
9.接口-》接口:继承(接口功能的扩展)
Comparison of classes and interfaces difference
between classes and interfaces:
实现 implement
只要类实现这个接口 接口当中的方法必须重写
Sort defined types : an interface override compareTo method to achieve comparable
custom type clone : clone method override implement Cloneable interface
Cloneable interface : none abstract method
i.e. empty interfaces: Interface tag - "sign of the current class can be cloned