java学习日记20230408-System类
System类
- exit退出当前程序;
- arraycopy:复制数组,比较适合底层调用,一般使用Arrays.copyOf完成复制数组;
- currentTimeMillens:返回当前时间距离1970-1-1的毫秒数
- gc运行垃圾回收机制
public class SystemMethod { public static void main(String[] args) { //0 表示退出状态 正常退出 //System.exit(0); System.out.println("1"); //arraycopy int[] src = {1,2,3}; int[] dest = new int[3]; /** * arams: * src – the source array. * srcPos – starting position in the source array.从源数组哪个索引开始拷贝 * dest – the destination array. * destPos – starting position in the destination data.把源数组的数据拷贝到目标数组的哪个索引 * length – the number of array elements to be copied.从源数组拷贝多少个数据到目标数组 */ System.arraycopy(src,1,dest,0,2); System.out.println(Arrays.toString(dest)); long second = System.currentTimeMillis(); System.out.println(second); } }

浙公网安备 33010602011771号