zoukankan      html  css  js  c++  java
  • java之的System类

     1 public class Demo3_System {
     2 
     3     /*
     4      * System类不能被实例化,所有的方法都是静态的
     5      * 成员方法:
     6      *   gc()   垃圾回收
     7      *   exit(int status)   退出程序 status 为0时是正常退出,非0位非正常退出
     8      *   public static long currentTimeMillis()  获取当前毫秒级时间
     9      *   public static void arraycopy(Object src, int srcPos, Object dest, int destpos, int length) 
    10      *   拷贝相应长度的数组到对应的数组中
    11      * 
    12      */
    13     public static void main(String[] args) {
    14         //demo1();
    15         //demo2();
    16         //demo3();
    17         demo4();
    18     }
    19 
    20     /*
    21      * 拷贝相应长度的数组中的值到目标数组中
    22      */
    23     public static void demo4() {
    24         int[] src = {1, 2, 3, 4, 5};
    25         int[] des = new int[8];
    26         for (int i = 0; i < des.length; i++) {
    27             System.out.println(des[i]);
    28         }
    29         System.out.println("********************");
    30         System.arraycopy(src, 0, des, 0, src.length);
    31         for (int i = 0; i < des.length; i++) {
    32             System.out.println(des[i]);
    33         }
    34     }
    35 
    36     /*
    37      * 获取当前时间的毫秒级时间
    38      */
    39     public static void demo3() {
    40         System.out.println(System.currentTimeMillis());
    41     }
    42 
    43     /*
    44      * 退出程序
    45      */
    46     public static void demo2() {
    47         System.out.println("正常运行");
    48         System.exit(0);
    49         System.out.println("结束了吗?");
    50     }
    51 
    52     /*
    53      * 调用垃圾回收机制
    54      */
    55     public static void demo1() {
    56         new Demo();
    57         System.gc();
    58     }
    59 }
    60 
    61 class Demo {
    62 
    63     //重写这个方法
    64     @Override
    65     protected void finalize() {
    66         System.out.println("垃圾被回收了!");
    67     }
    68     
    69 }
  • 相关阅读:
    使用python实现深度神经网络 1(转)
    OHDSI——数据标准化
    TensorFlow相关
    语言模型和共现矩阵(转)
    cd4与cd8比值的意义
    python之使用set对列表去重,并保持列表原来顺序(转)
    Python 汉字转拼音
    Hadoop的启动和停止说明
    Scikit-learn 概述
    病历智能分析系统的研究与实现(转)
  • 原文地址:https://www.cnblogs.com/jiangjunwei/p/9196966.html
Copyright © 2011-2022 走看看