System类的概述和方法使用

 

long start = System.currentTimeMillis();  程序开始执行的时间点    单位:毫秒
for(int i =0;i<1000;i++) {
System.out.println("*");
}
long end = System.currentTimeMillis();    程序执行结束的时间点   单位:毫秒
System.out.println(end-start);         计算出程序执行耗时   单位:毫秒

 

System.gc();//运行垃圾回收器
  System.exit(0);//正常终止,退出jvm虚拟机

 

 

 

int [] sarc = {11,22,33,44};
int [] dest = new int[4];
for(int i =0;i<dest.length;i++) {
System.out.println(dest[i]);    
}
System.arraycopy(sarc, 0, dest, 0, sarc.length);   把老数组复制到新数组中
for (int i = 0;i<dest.length;i++) {
System.out.println(dest[i]);
}

posted @ 2021-04-20 20:34  一块  阅读(88)  评论(0编辑  收藏  举报