Java system类
System类位于java.long包下,使用的时候不需要导包
System类包含一些有用的类字段和方法
System不能被实例化
System类的字段
System类常用方法
system类常用方法主要有两个:arraycopy()和currentTimeMillis()
arraycopy()
表示从指定源数组中复制一个数组
Src 源数组
srcPos 源数组中的起始位置
dest 目标数组
destPos 目标数组中的起始位置
Length 要复制的数组元素的数量
例子:
int[] arr11= {0,1,2,3,4};
int[] arr22= {5,6,7,8,9};
System.arraycopy(arr11, 0, arr22, 2, 2);
System.out.println(Arrays.toString(arr22));
注意点arr2的数据被覆盖了,而不是插入到前面
currentTimeMillis()****
Public static long currentTimeMillis()
返回以毫秒为单位的当前时间
常用于计算时间间隔,测试程序效率
例子:
long aa=System.currentTimeMillis();
for(int i=0;i<10000;i++) {
System.out.println();
}
long bb=System.currentTimeMillis();
System.out.println(bb-aa);