【JavaSE】System 类
        【摘要】 【JavaSE】System 类
    
    
    
    System类常见方法和案例
1. exit 退出当前程序
	System.out.println("ok1");
	//1. exit(0) 表示程序退出
	//2. 0 表示一个状态 , 正常的状态
	System.exit(0);
	System.out.println("ok2");
 
 
2. arraycopy:复制数组元素,比较适合底层调用,一般使用
	//arraycopy :复制数组元素,比较适合底层调用,
	// 一般使用Arrays.copyOf完成复制数组
	
	int[] src = {1,2,3};
	int[] dest = new int[3];// dest 当前是 {0,0,0}
	
	//解读:
	//1. 主要是搞清楚这五个参数的含义
	//2.
	//     源数组
	//     * @param      src      the source array.
	//     srcPos: 从源数组的哪个索引位置开始拷贝
	//     * @param      srcPos   starting position in the source array.
	//     dest : 目标数组,即把源数组的数据拷贝到哪个数组
	//     * @param      dest     the destination array.
	//     destPos: 把源数组的数据拷贝到 目标数组的哪个索引
	//     * @param      destPos  starting position in the destination data.
	//     length: 从源数组拷贝多少个数据到目标数组
	//     * @param      length   the number of array elements to be copied.
	System.arraycopy(src, 0, dest, 0, src.length);
	System.out.println("dest=" + Arrays.toString(dest));//[1, 2, 3]
 
 
System.arraycopy(src, 0, dest, 1, 2);
System.out.println("dest=" + Arrays.toString(dest));
 
 
3. currentTimeMillens:返回当前时间距离1970-1-1的毫秒数
System.out.println(System.currentTimeMillis());
 
 
- 可以使用时间戳工具来转换成时间单位

 
4. gc:运行垃圾回收机制 System.gc();
            【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
                cloudbbs@huaweicloud.com
                
            
        
        
        
        
        
        
        - 点赞
 - 收藏
 - 关注作者
 
            
           
评论(0)