1.将一个基本数据类型数组的引用赋值给另一个数组 public class Array_copy { int[] array1=new int[]{1,2,3,4,5,6}; int[] array2=array1;//将array1的引用赋值给array2,两数组指向同一个内存空间 public static void main(String args[]){ Array_copy ac = new Array_copy(); for (int i=0;i<ac.array1.length;i
可以重写静态方法,但重写后的静态方法不支持多态. 其实static根本就没有重写之说.static方法引用的时候应该用类名来引用,而不是对象.同时static方法不参与继承,所以在继承体系里面也不存在重载的说法. 不能被重写,例子: class A{ public static void a(){ System.out.println("a"); } } class B extends A{ public static void a(){ System.out.println(&quo
MSDN上的定义 Use the static modifier to declare a static member, which belongs to the type itself rather than to a specific object. The static modifier can be used with classes, fields, methods, properties, operators, events, and constructors, but it can
创建内容类的方式通过外部类的实例对象来创建 public class AA { int a =1; class BB { int b=3 ; } public static void main(String[] args) { AA a =new AA(); BB b=a.new BB(); System.out.println(a.a); System.out.println(b.b); } } 利用static修饰后,能够直接创建 public class AA { int a =1; st
一.final final是不变的,最终的意思.可以用来修饰变量,方法,类. 1. 修饰变量 private final int a = 2; private final int b; // final 空白,必须在构造函数中指定初始值. // 因为static 的缘故,必须在定义时指定初始值,不能在构造函数中指定初始值. // 因为访问static 变量根本不用调用构造函数啊,笨蛋! private static final int c = 3; 2. 修饰方法 表示该方法不能被子类重写.使用