1.arraycopy
import java.util.Arrays;
//arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
//从指定源数组中复制一个数组,复制从指定的位置开始,到目标数组的指定位置结束。
//src - 源数组。
//srcPos - 源数组中的起始位置。
//dest - 目标数组。
//destPos - 目标数据中的起始位置。
//length - 要复制的数组元素的数量。
public class System1
{
public static void main(String[] args)
{
int[] SrcArr = {1,56,69,9,3,};
int[] destArr = new int[4];
System.arraycopy(SrcArr, 2, destArr, 0, 2);
System.out.println(Arrays.toString(destArr));
//[69, 9, 0, 0]
}
}
2.
import java.io.IOException;
import java.util.Properties;
//System.currentTimeMillis()
//当前时间与过去某一个时刻的差值
//exit() 退出jvm
//gc() 建议jvm赶快启动垃圾回收器
//System.getenv("JAVA_HOME") 返回一个环境变量
//System.getProperties(); 返回系统信息
public class CurrentTimeMillis1
{
public static void main(String[] args)throws IOException, InterruptedException {
System.out.println(System.currentTimeMillis());
//System.exit(1);//无论是0和1都退出
System.out.println("hello world");
System.out.println(System.getenv("JAVA_HOME"));
// Properties p = System.getProperties();
// p.list(System.out);
String s = System.getProperty("os.name");//显示一个属性
System.out.println(s);
Runtime runtime = Runtime.getRuntime();//throws IOException
Process process = runtime.exec("C:\\Windows\\notepad.exe");//启动记事本
Thread.sleep(500);//throws InterruptedException
process.destroy();//杀死子进程 把记事本关掉
System.out.println("jvm中的空闲内存量"+ runtime.freeMemory());
System.out.println("jvm中的空闲内存量"+ runtime.maxMemory());
System.out.println("jvm中的空闲内存量"+ runtime.totalMemory());
}
}
运行结果:
1476706657681
hello world
D:\jdk\
Windows 8
jvm中的空闲内存量127244592
jvm中的空闲内存量1892155392
jvm中的空闲内存量127926272