System类

97 阅读1分钟
  1. 主要用于获取系统的属性数据和其他操作,构造方法是私有的。
  2. 常见的一些方法: 这里介绍一下arraycopy方法:
package com.Class.SystemClass;

public class demo {

    public static void main(String[] args) {
        //1. arraycopy 复制
        //src-原数组 srcPos-从哪个位置开始复制0 dest-目标数组 destPos-目标数组的位置 length-复制的长度
        int[] arr = {20, 18, 39, 3,25,36,24,85,26};
        int[] dest = new int [10];
        System.arraycopy(arr, 0, dest, 0, 5);
        for (int i = 0; i < dest.length; i++) {
            System.out.println(dest[i]);
        }

    }

}

currentTimeMillis():在我前面的博客StringBuffer和StringBuilder这两个类的讲解中有说到,不懂得可以再去看看。

gc()方法:你使用了,JVM可能也不会理你,也可能不去回收这些垃圾,所以,个人感觉,了解就好。

exit()方法:主动退出程序,在你使用了之后,自动退出程序,在System.exit()后得语句都不会实行。

  1. System类更常见的方法还是那些关于IO流的,接下来我会慢慢添加相关的知识。