System类

System类

示例代码:

public class Demo3 {
    public static void main(String[] args) {
        //arrayCopy  数组复制
        int[] src = {12, 34, 45, 56, 67, 45};
        int[] dest = new int[8];
        System.arraycopy(src, 0, dest, 0, src.length); //1.原数组  2.从哪个位置开始赋值  3.目标数组  4.目标数组的位置  5.复制的长度
        for (int i = 0; i < dest.length; i++) {
            System.out.println(dest[i]);
        }

        //currentTimeMillis()   获取到现在的毫秒数  实现计时
        long start = System.currentTimeMillis();
        for (int i = -999999999; i < 9999999; i++) {
            for (int j = -999999; j < 9999999; j++) {
                int result = i + j;
            }
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);

        //gc()  告诉垃圾回收器回收垃圾


        //推出JVM
        System.exit(0);
        System.out.println("结束了"); 
    }

}
原文地址:https://www.cnblogs.com/qiudajiang/p/13256267.html