关于继承方面的构造函数等知识汇总
Constructors Are Not Inherited
构造函数是不会继承的,若是子类调用父类构造函数,需要先加上super()函数(不加会默认用无变量的super())
Abstract classes
Interface
- All methods must be public.
- All variables must be public static final.
- Cannot be instantiated
- All methods are by default abstract unless specified to be
default
- Can implement more than one interface per class
Abstract
- Methods can be public or private
- Can have any types of variables
- Cannot be instantiated
- Methods are by default concrete unless specified to be
abstract
- Can only implement one per class
抽象基本囊括interface的功能,甚至更多
本文由作者按照
CC BY 4.0
进行授权