class ArrayCopy {
static int a[] = { 1, 2, 3, 4, 5, 6 };
static int b[] = { 10, 9, 8, 7, 6, 5, 4,};
public static void main(String[] args)
{
System.arraycopy(a,0,b,0,5);
for(int i=0; i<6; i++)
System.out.println("ff:"+b[i]);
}
}
static int a[] = { 1, 2, 3, 4, 5, 6 };
static int b[] = { 10, 9, 8, 7, 6, 5, 4,};
public static void main(String[] args)
{
System.arraycopy(a,0,b,0,5);
for(int i=0; i<6; i++)
System.out.println("ff:"+b[i]);
}
}
1. 表达式不可以直接写在类里。
System.arraycopy(a,0,b,0,5); 得写在method 内2. static 的方法只能访问 static 的变量