1.System.arraycopy()
int[] a = {1,2,3,4};
int[] b = new int[5];
/*for(int j = 0 ; j<a.length ; j++)
{
System.out.println("前:"+a[j]);
}*/
for(int j = 0 ; j<b.length ; j++)
{
System.out.println("前:"+b[j]);
}
System.out.println("--------------------------------------------------------");
//public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
// 拷贝对象,开始拷贝位置,拷贝到达对象,拷贝开始位置,拷贝长度
//该方法的作用是数组拷贝,也就是将一个数组中的内容复制到另外一个数组中的指定位置,
//由于该方法是native方法,所以性能上比使用循环高效。
System.arraycopy(a,1,b,2,3);
/*for(int i = 0 ; i<a.length ; i++)
{
System.out.println("后:"+a[i]);
}*/
for(int i = 0 ; i<b.length ; i++)
{
System.out.println("后:"+b[i]);
}
2.System.currentTimeMillis();
//获得的将是一个长整型的数字,该数字就是以差值表达的当前时间,与格林尼治时间相比。
long start = System. currentTimeMillis();
for(int i = 0;i < 100000000;i++){
int a = 0;
}
long end = System. currentTimeMillis();
long time = end -start;
System.out.println(end);
System.out.println(start);
System.out.println(time);
3.System.getProperty();
System.setProperty("love", "it is my love");
System.out.println(System.getProperty("love"));
/*public static String getProperty(String key)
该方法的作用是获得系统中属性名为key的属性对应的值*/
System.out.println("java运行时环境版本:"+System.getProperty("java.version"));
System.out.println("java安装目录:"+System.getProperty("java.home"));
System.out.println("操作系统名称:"+System.getProperty("os.name"));
System.out.println("操作系统版本:"+System.getProperty("os.version"));
System.out.println("用户账户名称:"+System.getProperty("user.name"));
System.out.println("用户的主目录:"+System.getProperty("user.home"));
System.out.println("当前用户工作目录:"+System.getProperty("user.dir"));
System.out.println("--------------------------------------------------------------");
Properties properties = System.getProperties();
for(Object key:properties.keySet()){
String keyStr=(String)key;
String value=properties.getProperty(keyStr);
System.out.println(keyStr+" --- "+value);
}
System.out.println("***************************************************");
Properties pro = new Properties();
try {
pro.load(new FileInputStream(new File("D:\\workspace\\Static_final_Const\\src\\conf.properties")));
} catch (FileNotFoundException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
} catch (IOException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
System.out.println(pro.getProperty("base"));
System.out.println(pro.getProperty("i"));
System.out.println(pro.getProperty("w"));
4.System.exis
//public static void exit(int status)
//该方法的作用是退出程序。其中status的值为0代表正常退出,非零代表异常退出。
//使用该方法可以在图形界面编程中实现程序的退出功能等