System的常用方法
- exit():推出当前程序
- arraycopy():复制数组
- currentTimeMillens():返回当前时间距离1970.1.1的毫秒数
- gc():运行垃圾回收机制
使用解释
arraycopy()
arraycopy(src,srcPos,dest,destPos,length);
arraycopy(src,0,dest,0,3);//示例
src-------代表要被复制的数组-源数组
srcPos0-------代表从源数组的0号下标开始赋值
dest-------代表把源数组的数据拷贝到哪个数组
destPos-----倒数第二个0代表把源数组的数据拷贝到目标数组的哪个索引开始
length-------3代表从源数组拷贝多少个元素
public class test2 {
public static void main(String[] args) {
int arr [] ={1,2,3,4,5};
int arr2 [] = new int [3];
System.arraycopy(arr,1,arr2,0,arr.length-2);
System.out.println(Arrays.toString(arr2));
}
}
上面代码代表着将arr数组的1号下标开始复制到arr2的0号下标处,一共复制3个。