一.重载:即同名方法不同参数;多态:同名同参方法,在具有继承关系的类中的动态选择
二.重载传入参数数据类型小于方法声明参数类型时,会被自动提升。char 类型会被直接提升为int。虚拟机就是用int表示char的。
三.static方法内部不能调用非static方法,反之可以。
四.对于方法局部变量,如果未初始化就调用,编译错误。成员变量则赋予默认值。
五.无论创建多少个对象,静态数据只占用一分存储区域。只在第一次调用的时候初始化。构造器实际也是static方法。
六.数组也是按引用(There are three kinds of reference types: the class types , the interface types , and the array types ,表示大小的成员length。打印数组数据。Arrays.toString(array)
七.
- 只有普通方法的访问是多态的,直接访问域将在编译时期解析。
- 静态方法的访问也没有多态。
- 构造函数调用顺序为积累 的成员函数、构造方法。
八. 静态成员初始化顺序
- 父类静态成员和静态初始化块 ,按在代码中出现的顺序依次执行
- 子类静态成员和静态初始化块 ,按在代码中出现的顺序依次执行
- 父类实例成员和实例初始化块 ,按在代码中出现的顺序依次执行
- 父类构造方法
- 子类实例成员和实例初始化块 ,按在代码中出现的顺序依次执行
- 子类构造方法
九. A public
member may be accessed by any class or interface. A private
member may be accessed only from within the class that contains its declaration. A member that is not declared public
, protected
, or private
is said to have default access and may be accessed from, and only from, anywhere in the package in which it is declared.
A protected
member of an object may be accessed only by code responsible for the implementation of that object. To be precise, a protected
member may be accessed from anywhere in the package in which it is declared and, in addition, it may be accessed from within any declaration of a subclass of the class type that contains its declaration, provided that certain restrictions are obeyed.