1 package test;
2
3
4 /*System类
5 *
6 * public static void gc() 运行垃圾回收器 只有在执行大量的对象的释放,才调用垃圾回收。
7 * public static void exit(int status)
8 * public static void
9 *
10 * */
11
12 public class Test01 {
13 public static void main(String[] args) {
14 Person p=new Person(22,"hello");
15 System.out.println(p);
16 p=null;
17 System.gc();
18
19 }
20 }
1 package test;
2
3 public class Person {
4 private int age;
5 private String name;
6 public Person() {
7 super();
8 // TODO Auto-generated constructor stub
9 }
10 public Person(int age, String name) {
11 super();
12 this.age = age;
13 this.name = name;
14 }
15 public int getAge() {
16 return age;
17 }
18 public void setAge(int age) {
19 this.age = age;
20 }
21 public String getName() {
22 return name;
23 }
24 public void setName(String name) {
25 this.name = name;
26 }
27 @Override
28 public String toString() {
29 return "Person [age=" + age + ", name=" + name + "]";
30 }
31 public void finalize() throws Throwable{
32 System.out.println("当前的对象被回后了"+this);
33 super.finalize();
34 }
35 }
1 package test;
2
3 /*System类
4 *
5 * public static void gc() 运行垃圾回收器 只有在执行大量的对象的释放,才调用垃圾回收。
6 * public static void exit(int status) 终止当前正在运行的jvm, 参数用作状态码,非0表示异常终止
7 * public static long currentTimeMillis() 以毫秒返回当前时间
8 *
9 *
10 * */
11
12 public class Test01 {
13 public static void main(String[] args) {
14 /*System.out.println("hello world");
15 System.exit(0);
16 System.out.println("accross the great wall");*/
17
18 //System.out.println(System.currentTimeMillis()); //1440386525027
19
20 //得到程序的运行时间
21 long start=System.currentTimeMillis();
22 for(int i=0;i<1000000;i++){
23 System.out.println(i);
24 }
25 long end=System.currentTimeMillis();
26 System.out.println(end-start);
27
28 }
29 }
1 package test;
2
3 import java.util.Arrays;
4
5 /*System类
6 *
7
8 *
9 * public static void arraycopy(Object src, //数组复制 从指定源数组中复制一个数组,复制从指定的位置开始,到目标数组的指定位置结束。
10 int srcPos,
11 Object dest,
12 int destPos,
13 int length)
14 * */
15
16 public class Test01 {
17 public static void main(String[] args) {
18 int[] arr={11,22,33,44,55,66,77};
19 int[] arr2={2,3,4,5,6,7,8};
20 System.arraycopy(arr, 1, arr2, 2, 3);
21 System.out.println(Arrays.toString(arr));
22 System.out.println(Arrays.toString(arr2));
23 }
24 }