1.二维数组是由若干个一维数组组成的一维数组,他的每一个元素都是一个一维数组。
2.for~each
*for(数据类型 变量 :数组)
语句;
*例如:for(int element : array)
System.out.println(element);
他会打印数组array中的每一个元素。
3.clone的用法
*相当于复制一个数组,例如:
int a[]={1,2,3,4,5};
int [] b=(int [])a.clone 得到一个与a数组相同的 数组b(二维数组也一样)。
4.静态变量与非静态变量的区别:
*非静态变量单独属于某个对象
*静态变量属于整个类
5.所有的对象都是实例成员变量,如果所属的对象没有被创 建,它们就不存在。如果外部使用它,需要先创建一个对 象,然后通过“对象名。变量名”来访问。
6.方法的调用:
*如果方法是被static修饰(静态方法)则可以用
类名.方法名 来调用
*否则就创建一个对象,用 对象名. 方法名 来调用
7.基本类型作为方法调用的参数:
*它所传递的实参的值是一个副本
*单值传递。实参本质上是一个可求值的表达式,它所求 出来的值是一个基本类型
*单向传递。方法内部可以修改形参的值,但这种修改不 会影响到对应的实参。
8.构造方法:
//是对象中第一个被执行的方法,主要用于申请内存, 对类 的成员变量进行初始化等操作。
*构造方法名称必须和类的名称完全相同。
*构造方法不能用static,final来修饰。一般也不用 private修饰,这会导致无法在外部创建对象。
*构造方法不能由对象显式的调用。一般通过new关键字 来调用,或者用this,super来调用。
9.静态方法与实例方法的区别
*在外部调用静态方法,用类名.方法名,也可以用
对象名.方法名。实例方法只有后面的方式,也就是说 用静态方法无需创建对象。
*静态方法在访问本类的成员时,只允许访问静态成员静 态成员(即静态成员变量和静态方法),而不允许成员 变量和实例方法;实例方法则无此限制。
10.子类对父类的继承:
*【修饰类符】class 子类名 extends 父类名{
类体
}
11.子类方法的访问权限与父类的不相同,但是只允许更宽 松,而不允许更严格。
12.Final修饰的方法是一个最终方法,他的子类不能覆盖该 方法。反之一个非最终方法,可以在子类中指定final 修饰符,将其变成最终方法。
Java规定,静态方法不允许被实例方法覆盖,同样,实 例方法也不允许被静态方法覆盖。也就是说,不允许出现 父类方法和子类方法覆盖时static修饰符发生变化。
13.使用super时:
*它只能同在构造方法中。
*他只能是第一条执行语句。
*一个构造方法中只能有一条super语句。
14.JAVA中实现重载的方法:
*在同一类中
*方法名称相同,参数不同
15.构造方法的重载:
相对于普通的成员方法,由于构造方法不能是static和 final类型,而且没有返回值,所以它比普通成员方 法更简单一些
16.重载参数的转换两条路径:
*byte→short→int→long→float→double
*char→int→long→float→double
17.重载与覆盖的区别:
*重载和覆盖的方法名称都相同,但重载要求参数列表不 同,而覆盖则要求参数列表完全相同。
*重载对于方法前面的修饰没有限制,而覆盖则对这些修 饰符的使用有限制。
*同一类中的方法能够相互重载,但不能相互覆盖。子类 对父类方法既可以冲在也可以覆盖。
*重载时,编译器在编译期间可以确定调用哪一个方法, 而覆盖则有可能在运行期间在可以确定。