System类

System类

System类,主要获取系统的属性数据和其他操作,构造方法私有

方法名说明
arraycopy()复制数组
currentTimeMillis();获取当前系统值,返回ms值
gc();建议JVM启动垃圾回收器回收垃圾
exit();退出JVM,如果参数为0表示正常退出,非0表异常退出
public static void main(String[] args) {

        //1.arraycopy:数组的复制
        //src,原数组
        //srcPos:从哪个位置开始复制0
        //dest;目标数组
        //destPos:目标数组的位置
        //length:复制的长度
        int[] arr = {20,18,15,8,1,35,6,11,21};
        int[] dest = new int[9];

        System.arraycopy(arr,4,dest,4,4);
        System.out.println(Arrays.toString(dest));
        for (int i:dest) {
            System.out.println(i);
        }
        //Arrays.copyof是使用System.arraycopy

        //2.currentTimeMillis获取时间,ms值
        System.out.println(System.currentTimeMillis());
        long start = System.currentTimeMillis();
        for (int i = 0; i < 99999; i++) {
            for (int j = 0; j < 99999; j++) {
                int result = i+j;
            }
        }
        long end = System.currentTimeMillis();
        System.out.println((end-start)+"ms");

        //3.System.gc();告诉垃圾回收器回收
        new Student("A",10);
        new Student("B",11);
        new Student("C",12);
        System.gc();

        //4.退出JVM
        System.exit(0);
        System.out.println("over");

    }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值