public class HSystem {
public static void main(String[] args) {
for (int i = 0; i < 10000; i++) {
new DemoClear();
System.gc();//运行垃圾回收器
}
}
}
class DemoClear{
public void scavenging(){
System.out.println("清理垃圾!");
}
}
-
获取程序运行时间(单位:毫秒)——currentTimeMillis
long startTime = System.currentTimeMillis(); //获取当前时间的毫秒值
for (int i = 0; i < 10000; i++) {
String a = "$100" + i;
System.out.println(a);
}
long endTime = System.currentTimeMillis();
long spendTime = endTime - startTime;
System.out.println(spendTime);
int[] arr = {11,22,33,44,55,66};
int[] arr1 = new int[6];
for (int i = 0; i < arr1.length; i++) {
System.out.println(arr1[i]);
}
System.out.println("-------------");
//将arr数组索引为0及以后的元素复制到arr1数组索引为0及以后的位置 复制长度为整个arr的长度
System.arraycopy(arr,0,arr1,0,arr.length);
for (int i = 0; i < arr1.length; i++) {
System.out.println(arr1[i]);
System.exit(0);//非0状态是异常终止,退出jvm
System.out.println("是否还运行");//不在运行