常用方法:
| 返回类型 | 方法和描述 |
|---|---|
static void |
arraycopy(Object src, int srcPos, Object dest, int destPos, int length) 数组复制 |
static long |
currentTimeMillis()返回当前时间(以毫秒为单位) |
static void |
exit(int status)终止当前运行的Java虚拟机。 |
static void |
gc()运行垃圾回收器。 |
static Properties |
getProperties()确定当前的系统属性。 |
static String |
getProperty(String key)获取指定键指示的系统属性。 |
static Map<String,String> |
getenv()返回当前系统环境的不可修改的字符串映射视图。 |
static String |
getenv(String name)获取指定环境变量的值。 |
java
public class System_ {
public static void main(String[] args) {
//exit 退出当前程序
//1.exit(0) 退出当前程序
//2.0-表示正常退出
System.out.println("ok1~");
System.exit(0);
System.out.println("ok2~");
//arraycopy
int[] src = {1, 2, 3};
int[] dest = new int[3]; //{0, 0, 0}
int[] dest1 = new int[3]; //{0, 0, 0}
/**
* 参数解释
* src -- the source array.原数组
* srcPos -- starting position in the source array. 从原数组的那个位置开始拷贝
* dest -- the destination array. 目标数组
* destPos -- starting position in the destination data.从目标数组的那个位置开始放入原数组的数据
* length -- the number of array elements to be copied.拷贝原数组的长度(拷贝几个元素)
*/
System.arraycopy(src, 0, dest, 0, 3);
System.out.println(Arrays.toString(dest));//[1, 2, 3]
System.arraycopy(src, 1, dest1, 1, 2);
System.out.println(Arrays.toString(dest1));//[0, 2, 3]
//currentTimeMillis 毫秒数
System.out.println(System.currentTimeMillis());
//gc 手动改调用垃圾回收机制
}
}