System

来源:互联网 发布:ladder mac版怎么用 编辑:程序博客网 时间:2024/05/17 03:18
package niu.cheng4;


import java.util.Arrays;


//System
//static InputStream in “标准”输入流。 
//static PrintStream out “标准”输出流。 
//




//System 类包含一些有用的类字段和方法。它不能被实例化。
//public static void gc()运行垃圾回收器。 
//public static void exit(int status)终止当前正在运行的 Java 虚拟机,参数用作状态码;根据惯例,非 0 的状态码表示异常终止。
//public static long currentTimeMillis()返回以毫秒为单位的当前时间
//public static void arraycopy(Object src,
// int srcPos,
// Object dest,
// int destPos,
// int length)从指定源数组中复制一个数组,复制从指定的位置开始,到目标数组的指定位置结束
//
//


public class SystemDemo {


/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
//public static void gc()运行垃圾回收器。 
Son s=new Son("xxx", xx);
System.out.println(s);//Son [name=xxx, age=xx]
s=null;
System.out.println(s);//null
System.gc();//垃圾回收器运行:Son [name=xxx, age=xx]
*/

/*
//public static void exit(int status)终止当前正在运行的 Java 虚拟机参数用作状态码;根据惯例,非 0 的状态码表示异常终止。
System.exit(0);
System.out.println("-----------");//终止了
*/

/*
//public static long currentTimeMillis()返回以毫秒为单位的当前时间
long start =System.currentTimeMillis();
for(int x=0;x<10000;x++){
System.out.println("helloworld"+x);
}
long end =System.currentTimeMillis();
System.out.println("跑完这段代码用时"+(end-start)+"毫秒");//跑完这段代码用时213毫秒
*/

//public static void arraycopy(Object src,int srcPos,Object dest,int destPos,int length)从指定源数组中复制一个数组,复制从指定的位置开始,到目标数组的指定位置结束
int[] x={1,2,3,4,5,6,7};
int[]y={2,3,4,5,6};
System.arraycopy(x, 2, y,0 , 2);
System.out.println(Arrays.toString(x));//[1, 2, 3, 4, 5, 6, 7]
System.out.println(Arrays.toString(y));//[3, 4, 4, 5, 6]
}
}
0 0
原创粉丝点击