java_15 System类

1.System类

  

2.System类方法

  (1)currentTimeMillis()
  

    public static void main(String[] args) {
		long start = System.currentTimeMillis();
		for (int i = 0; i < 10000; i++) {
			System.out.println(i);
		}
		long end = System.currentTimeMillis();
		System.out.println("------------");
		System.out.println(end - start);
	}

 
    (2)arraycopy(Object src, int srcPos, Object dest, int destPos, int length):   复制数组到目标数组

    public static void main(String[] args) {
		int[] arr = {23,56,12,65,98};			//定义arr数组
		int[] resu = new int[3];				//定义长度为3的resu数组
		Arrays.sort(arr);						//将arr数组从小到大排序
		System.arraycopy(arr, 0, resu, 0, 3);//将arr数组中前3 个,即最小的3位数赋值给resu数组
		for (int i = 0; i < resu.length; i++) {	//打印
			System.out.print(resu[i]+"\t");
		}
	}

 

  (2)exit ();


  (3)gc()


  (4)getProperties()



猜你喜欢

转载自www.cnblogs.com/smxbo/p/10685466.html