zoukankan      html  css  js  c++  java
  • Java中System类

    System类包含一些有用的类字段和方法,他不能被实例化

    方法:
    public static void gc():运行垃圾回收器
    public static void exit(int status):终止当前正在运行的Java虚拟机。参数用作状态码;非0的状态码表示异常终止
    public static long currentTimeMillis():返回以毫秒为单位的当前时间
    public static void arraycopy(Object src,int srcPos,Object dest,int destPos,int length)
    从指定源数组中复制一个数组,复制从指定的位置开始,到目标数组的指定位置结束。

    public static void main(String[] args){
    //public static void exit(int status):终止当前正在运行的Java虚拟机。参数用作状态码;非0的状态码表示异常终止
    System.out.println("我们喜欢林青霞(东方不败)");
    System.exit(0); //当写上这句代码后虚拟机执行这里后就会退出 所以只输出了我们喜欢林青霞(东方不败)
    System.out.println("我们也喜欢唱歌");

    //public static long currentTimeMillis():返回以毫秒为单位的当前时间
    System.out.println(System.currentTimeMillis());//1550049955435
    //单独得到这样的时间目前对我们来说意义不大
    //那么,有什么作用呢?
    //要求:请给下面循环统计运行时间
    long start = System.currentTimeMillis();
    for(int x=0;x<100000;x++){
    System.out.println("hello"+x);
    }
    long end = System.currentTimeMillis();
    System.out.println("共耗时:"+(end-start)+"毫秒");

    //public static void arraycopy(Object src,int srcPos,Object dest,int destPos,int length)
    //定义数组 原数组 原数组起始位 目的数组 的起始位置 需要长度
    int[] arr = {1,2,3};
    int[] arr2 = {4,5,6,7};

    System.arraycopy(arr, 0, arr2, 0, 2);
    System.out.println(Arrays.toString(arr));
    System.out.println(Arrays.toString(arr2));
    }

  • 相关阅读:
    MS SQL2000 && 2005转出数据字典
    基于角色的访问控制'的权限管理的数据库的设计实现
    ANSI SQL / T SQL / PLSQL
    MS SQL系統資料表內容
    关闭不需要服务 为Windows系统提速
    Form.Enctype屬性
    流程圖
    ASPSmartUpload祥解
    数据排序常见算法(JS版)
    如何实现定时开机
  • 原文地址:https://www.cnblogs.com/lszbk/p/12318413.html
Copyright © 2011-2022 走看看