System类的使用

1.System类:

  不能被实例化,调用方式:  System.方法

2.用于计算程序执行的时间,currentTimeMillis()方法

  System.currentTimeMillis();

public static void main(String[] args) {
//程序未运行的当前时间
long t = System.currentTimeMillis();
//System.out.println(t);
for (int i = 0; i < 100000; i++) {
System.out.println(i); }
//程序运行完的时间
long end = System.currentTimeMillis();
//程序结束用的时间
System.out.println(end-t);
}

3.垃圾回收 ,gc();方法

Person:

public class Person {
//finalize最终的
public void finalize(){
System.out.println("垃圾收取了");
}
}
TestPerson:
public static void main(String[] args) {
fun();
}
public static void fun(){
new Person();
new Person();
new Person();
new Person();
System.gc();
}
上一篇:SignalR 2.0 入门与提高 转载https://www.cnblogs.com/vance/p/SignalR.html


下一篇:[转] js对象浅拷贝和深拷贝详解