7.system类

常用方法:

返回类型 方法和描述
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 手动改调用垃圾回收机制
    }
}
相关推荐
SL_staff1 小时前
BI落地失败的3个技术断点:从数据接入、自助分析到服务闭环的工程实践
java·数据分析·数据可视化
大风起兮云飞扬丶1 小时前
Java——线程池
java·开发语言
文丑颜不良啊2 小时前
LeetCode276~300题目解析
java·leetcode
Vegetable_xu2 小时前
Spring Bean 循环依赖:为什么有时能过、有时启动就挂
java·spring·mybatis
avi91113 小时前
【AI教人】在Inspector显示所有Delegate-Odin Inspector之三
java·前端·算法·delegate·inspector·editor扩展·unity editor
青春不朽5123 小时前
Python 的 list append 为什么是均摊 O(1)?拆开过度分配那张表,看容量翻倍背后的暗账
java·python·list
小羊没烦恼!4 小时前
.NET 11 Runtime Async 详解
java·运维·开发语言·javascript·python
哇嘎呀4 小时前
RHCSA题目
java·服务器·前端
SL_staff4 小时前
企业知识平台细粒度权限设计实践:从成员组、文档库到操作级的三层防线
java·开源·全栈