2.系统相关类

文章目录

一.System

系统的类

二.Runtime

JVM运行过程的类

image

新建SystemDemo.java

public class SystemDemo {
	public static void main(String[] args) {
		String str = "ABCDEF";
		char[] c = str.toCharArray();
		char[] c1 = new char[10];
		//拷贝数组方法
		System.arraycopy(c,1,c1,1,4);
		System.out.println(Arrays.toString(c1));
		
		//返回距离标准时间的毫秒数
		Long l = System.currentTimeMillis();
		System.out.println(l);
		
		//退出JVM
		//System.exit(0);
		System.out.println("已经退出");
		
		new SystemDemo();
		new SystemDemo();
		new SystemDemo();
		//强制使用垃圾回收器
		Runtime.getRuntime().gc();
	}
	@Override
	protected void finalize() throws Throwable {
		super.finalize();
		System.out.println("我被回收了.......");
	}
}
发布了58 篇原创文章 · 获赞 0 · 访问量 724

猜你喜欢

转载自blog.csdn.net/huang_kuh/article/details/104884762