30-System类

System类

  • System系统类,主要用于获取系统的属性数据和其他操作,构造方法私有的(不需要创建对象,方法也是静态的)

常用方法

  • arraycopy(); 复制数组
  • currentTimeMillis(); 获取当前系统时间,返回的是毫秒值
  • gc(); 建议JVM赶快启动垃圾回收期回收垃圾
  • exit(int status); 推出JVM,参数是0表示正常退出,非0表示异常退出
        //arraycopy
        //src:源数组 srcPos:从那个位置开始复制  dest:目标数组  destPos:目标数组位置  length:长度
        int[] arr = {20,18,15,8,35,26,45,90};
        int[] dest = new int[8];
        System.arraycopy(arr,4,dest,4,4);
        for (int i : dest) {
            System.out.println(i);
        }
        //currentTimeMillis();
        System.out.println(System.currentTimeMillis());

        //gc();
        System.gc();
        
        //exit();
        System.exit(0);
posted @   呆头尖瓜  阅读(4)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示