public class SystemTest { public static void main(String[] args) { //测试arraycopy方法,注意,目的空间必须提前分配 int[] src = {1,2,3,4,5,6,7,8,9}; System.out.println("System.arraycopy"); int[] dst = new int[src.length]; System.arraycopy(src, 0, dst, 0, src.length); System.out.println("src = "+Arrays.toString(src)); System.out.println("dst = "+Arrays.toString(dst)); //同样是拷贝,Arrays.copyOf方法就不需要手动开辟空间 System.out.println("Arrays.copyOf"); int[] dst1 = Arrays.copyOf(src, src.length); System.out.println("src = "+Arrays.toString(src)); System.out.println("dst1 = "+Arrays.toString(dst1)); //测试currentTimeMillis() System.out.println("currentTimeMillis "+System.currentTimeMillis()); //测试nanoTime(),单独输出的结果没有仍和意义,此函数只能用来计算时间差 System.out.println("nanoTime "+System.nanoTime()); long dt=System.nanoTime(); dt = dt - System.nanoTime(); System.out.println("dt = "+dt); //测试getenv(),注意遍历Map的用法,不是很理解 System.out.println("System.getenv"); Map<String,String> env = System.getenv(); Iterator it = env.entrySet().iterator(); while(it.hasNext()) { Map.Entry a = (Map.Entry)it.next(); System.out.println("<"+a.getKey()+"> = <"+a.getValue()+">;"); } //getProperties(),注意遍历Map的用法,不是很理解 System.out.println("System.getProperties"); Properties p = System.getProperties(); p.list(System.out); System.out.println("Hello World!"); } } |