package test;

import java.util.Properties;
import java.util.Set;

public class test6 {
public static void main(String[] args) {
time();
property();
copy();
}
//System
// 系统属性相关:getProperties getProperty(String key)
// 时间相关:返回值long 代表从19**到现在的时间间隔
// 数组copy:可能发生数组越界异常
public static void property() {
Properties properties = System.getProperties();
System.out.println(properties);
//
Set<String> propertynames = properties.stringPropertyNames();
for (String key : propertynames) {
System.out.println(key + "----->" + System.getProperty(key));
}
}


public static void time() {
long startTime = System.currentTimeMillis();
int sum = 0;
for (int i = 0; i < 100000000; i++) {
sum += i;
}
long endTime = System.currentTimeMillis();
System.out.println("程序运行时间为:" + (endTime - startTime));
}


public static void copy() {
int[] source = {102, 102, 103, 104, 105, 106};
int[] target = {201, 202, 203, 204, 205, 206, 207};
System.arraycopy(source, 2, target, 3, 4);//可能发生数组越界
for (int i = 0; i < target.length; i++) {
System.out.println(i + ":" + target[i]);
}
}
}
package test;

public class test7 {
public static void main(String[] args) {
//Runtime
// 功能:对应当前JAVA程序对应的虚拟机环境,可以获取JAVA虚拟机占据的内存等信息
Runtime runtime = Runtime.getRuntime();

System.out.println(runtime.totalMemory());

System.out.println(runtime.maxMemory());

System.out.println(runtime.freeMemory());

System.out.println(runtime.availableProcessors());
}

}