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 手动改调用垃圾回收机制
    }
}
相关推荐
非优秀程序员31 分钟前
第04章 邮箱大战,163 与 QQ 的暗战|《互联网产品恩仇录》
java·vue.js·架构
知已难寻1 小时前
Docker 入门:容器技术与 Docker 基础
java·运维·服务器·docker·云原生·容器
文丑颜不良啊3 小时前
LeetCode2481~2500题目解析
java·leetcode
Flynn Liang4 小时前
同一需求三套写法:用 Spring AI、LangChain4j、AgentScope Java 各实现一个带工具调用的 RAG 助手(实战对比)
java·人工智能·大模型·架构设计·spring ai·langchain4j·agentscope
聪明的笨猪猪5 小时前
实际工程问题:AI 生成 Spring Cache(@Cacheable / @CachePut / @CacheEvict)缓存注解踩坑
java·经验分享·面试·ai编程
愿有所息5 小时前
记一次 ARM64 + JDK8 上 fastjson2 的诡异数据错乱
java
秋饼5 小时前
MCP 2026-07-28 无状态协议大改版:Spring AI 2.1 多轮往返请求与网关路由落地
java·ai·技术分享·后端开发
SL_staff7 小时前
JVS-BI 实战:业务人员如何用零代码 ELT + 可视化配置构建实时经营分析闭环
java·spring·全栈
SL_staff7 小时前
企业AI落地难?JVS-AI渐进式实践:安全可控、小切口验证、标准化沉淀与规模化复制
java·开源·aigc
SL_staff8 小时前
JVS数字底座实践:构建企业级统一内容管理平台的技术路径
java·产品