System类的常用方法
package Demo03;
public class SystemDemo {
public static void main(String[] args) {
System.out.println("开始");
System.exit(0);
//终止当前运行的Java虚拟机,非0表示异常终止
System.out.println("结束");//结束程序的运行,可以注释掉,否则下面的代码无法执行
// 返回当前时间与(1970年01月01日的差距,单位为毫秒)
System.out.println(System.currentTimeMillis());
// 返回当前时间与(1970年01月01日的差距,单位为年)
System.out.println(System.currentTimeMillis()*1.00/1000/60/60/24/365);
// 使用currentTimeMillis()可以计算出运行一个程序需要多长时间
long start = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
System.out.println(i);
}
long end = System.currentTimeMillis();
System.out.println("共耗时"+(end-start)+"毫秒");
}
}