一. 继承的特点
1. 继承的特点:
- 子类继承父类
// 从事务的特征来说,子类会继承父类的所有特征
// 从代码操作的角度来说,父类中私有的属性,方法在子类中是不能直接使用的
- 子类继承父类时,构造器是不能被继承的
- 子类继承父类时,在子类的构造器中一定要去调用父类的构造器,默认情况下是调用调用父类的无参构造;如果父类没有无参构造,那么在子类的构造器首行,必须手动调用父类的有参构造
- java中只支持单继承,即一个java类中只能有一个直接父类
- java支持多层继承,即父类还可以有父类
- 一个java类可以同时有很多个子类
- 子类可以扩展父类没有的属性、方法
When nothing seems to help, I go look at a stonecutter hammering away at his rock, perhaps a hundred times without as much as a crack showing in it. Yet at the hundred and first blow it will split in two, and I know it was not that blow that did it, but all that had gone before. -- Jacob Riis