java常用类-System

主要用于获取系统的属性数据和其他操作,构造方法私有;

static void arraycopy(src,srcPos,dest,destPos,length); 复制数组
static long currentTimeMillis(); 获取当前系统时间,返回毫秒值
static void gc(); 建议JVM启动垃圾回收器回收垃圾
static void exit(int status); 退出JVM,0:正常退出,非0:异常退出

import java.util.Date;
public class SystemDemo {
    public static void main(String[] args) {
        //1.arraycopy() 赋值数组
        int[] arr = {0, 1, 2, 3, 4, 5};
        int[] dest = new int[8];
        System.arraycopy(arr,1,dest,0,4);
        for (int n:dest) {
            System.out.println(n);
        }
        //2.currentTimeMillis() 获取毫秒数
        long time=System.currentTimeMillis();
        System.out.println(time);
        Date date= new Date();
        time=date.getTime();
        System.out.println(time);
        //3.gc() 回收垃圾
        Student s1=new Student("A",1);
        Student s2=new Student("B",2);
        new Student("C",3);
        new Student("D",4);
        new Student("E",4);
        new Student("F",4);
        System.gc();//回收未执行?
        //4.exit() 退出JVM
        System.exit(0);
        System.out.println("程序结束了");
    }
}
posted @   老李学Java  阅读(20)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示