java常用类-System
主要用于获取系统的属性数据和其他操作,构造方法私有;
static void arraycopy(src,srcPos,dest,destPos,length); 复制数组
static long currentTimeMillis(); 获取当前系统时间,返回毫秒值
static void gc(); 建议JVM启动垃圾回收器回收垃圾
static void exit(int status); 退出JVM,0:正常退出,非0:异常退出
import java.util.Date;
public class SystemDemo {
public static void main(String[] args) {
//1.arraycopy() 赋值数组
int[] arr = {0, 1, 2, 3, 4, 5};
int[] dest = new int[8];
System.arraycopy(arr,1,dest,0,4);
for (int n:dest) {
System.out.println(n);
}
//2.currentTimeMillis() 获取毫秒数
long time=System.currentTimeMillis();
System.out.println(time);
Date date= new Date();
time=date.getTime();
System.out.println(time);
//3.gc() 回收垃圾
Student s1=new Student("A",1);
Student s2=new Student("B",2);
new Student("C",3);
new Student("D",4);
new Student("E",4);
new Student("F",4);
System.gc();//回收未执行?
//4.exit() 退出JVM
System.exit(0);
System.out.println("程序结束了");
}
}
本文来自博客园,作者:老李学Java,转载请注明原文链接:https://www.cnblogs.com/JasonPro/p/15910484.html
浙公网安备 33010602011771号