常用方法
public class Test {
public static void main(String[] args) {
// exit 退出当前程序
// exit() 中的参数表示程序的状态,0表示正常状态
// System.exit(0);
// arraycopy 复制数组元素,比较适合底层调用
// 一般使用 Arrays.copyOf 复制数组,该方法底层就是调用的 arraycopy 方法
int arr[] = {1, 2, 3};
int newArr[] = new int[3]; // 初始为 [0, 0, 0]
/*
* 第一个参数:原数组
* 第二个参数:从原数组的哪个位置开始拷贝
* 第三个参数:目标数组
* 第四个参数:从目标数组的哪个位置开始放
* 第五个参数:拷贝几个元素
* 下面的意思就是:
* 从 arr 数组的第0个位置开始,拷贝3个元素,从 newArr 的第0个位置开始依次放这三个元素
*/
System.arraycopy(arr, 0, newArr, 0, 3);
System.out.println(Arrays.toString(newArr));
// currentTimeMillens 返回当前时间距离 1970-1-1 00:00:00 的毫秒数
System.out.println(System.currentTimeMillis());
// gc 运行垃圾回收机制 System.gc() (前面讲过,不再举例)
}
}