范例1:数组拷贝:public static void arraycopy(Object stc,int strPos,Object dest,int destPos,int length)
public class Demo {
public static void main(String[] args) throws Exception {
int[] num = new int[] { 55, 77, 22, 88, 99 };
int[] temp = new int[4];
System.arraycopy(num, 0, temp, 0, 4);
for (int i = 0; i < temp.length; i++) {
System.out.println(temp[i]);
}
}
}
=============分割线=============
范例2:取得当前系统时间:public static long currentTimeMillis()
public class Demo {
public static void main(String[] args) {
long start = System.currentTimeMillis();
String str = "";
for (int i = 0; i < 2000; i++) {
str += i;
}
long end = System.currentTimeMillis();
System.out.println("消耗的时间是:" + (end - start));
}
}
=============分割线=============
范例3:finalize()方法:protected void finalize()throws Throwable
class Message {
public Message() {
System.out.println("Nice");
}
@Override
protected void finalize() throws Throwable {
System.out.println("Good Morining");
System.out.println("Good Evening");
}
}
public class Demo {
public static void main(String[] args) {
Message msg = new Message();
msg = null;
System.gc();
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/aad9a2558cda5944eca892f21f23195c.png)