java System类

System.out 退出当前类

public class System01 {
    public static void main(String[] args) {
        System.out.println("ok1");

        // 0表示程序正常退出
        System.exit(0);
        
        System.out.println("ok2");
    }
}

//输出
ok1

Process finished with exit code 0

System.arraycopy: 复制数组元素

public class System02 {
    public static void main(String[] args) {
        int[] src = {1, 2, 3};
        int[] dest = new int[3];
        /**
         * Params:
         * 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, 0, dest, 0, 3);

        // [1, 2, 3]
        System.out.println(Arrays.toString(dest));
    }
}

System.currentTimeMillens: 返回当前时间距离1970-01-01的时间差

public class System03 {
    public static void main(String[] args) {
        System.out.println(System.currentTimeMillis());
    }
}
// 输出
1616550368282

gc:运行垃圾回收机制 System.gc();

public class System03 {
    public static void main(String[] args) {
        System.gc();
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值