zoukankan      html  css  js  c++  java
  • System类

    System类介绍的比较简单

    我们给出定义,System中代表程序所在系统,提供了对应的一些系统属性信息,和系统操作。

    System类不能手动创建对象,因为构造方法被private修饰,阻止外界创建对象。System类中的都是static方法,类名访问即可。在JDK中,有许多这样的类。

    System的方法中有:

                         1.System.currentTimeMillis(获取毫秒值)

                          2.System.exit():打断虚拟机运行,()里面传int类型的值,写0是正常状态停止运行
                          3.System.gc是系统垃圾回收机制(本篇不详细)

                          4.getProperty(String key) 用来获取指定(字符串名称)中所记录的系统属性信息    

                         5. System.arraycopr(源数组,要复制的起始下标,目标数组,目标数组要复制的下标,复制的位数)

    package com.oracle.demo01;
    public class Demo04 {
    public static void main(String[] args) {
      for(int i=0;i<10;i++) {
         System.out.println(i);
         if(i==5) {
           //结束程序
           System.exit(0);
         }
      }
    }
    }
    

    package com.oracle.demo01;
    public class Demo06 { public static void main(String[] args) { //赋值数组 int[] arr= {1,2,3,4,5,6}; int[] arr2=new int[3];//覆盖原始数组,超长度就越界 System.arraycopy(arr, 2, arr2, 0, 3); // System.arraycopr(源数组,要复制的起始下标,目标数组,目标数组要复制的下标,复制的位数) for(int i=0;i<arr2.length;i++) { System.out.println(arr2[i]); } } }
    package com.oracle.demo01;
    public class Preson {
    protected void finalize() throws Throwable { 
    
    finalize是O bj ect 类的一个方法,在垃圾收集器执行的时候会调用被回收对象的此方法,
    
    可以覆盖此方法提供垃圾收集时的其他资源回收,例如关闭文件等。
    
      System.out.println("对象被回收了");
    
    }
    
    }
  • 相关阅读:
    KL散度、JS散度和交叉熵
    np.dot()计算两个变量的乘积
    numpy 相关统计
    sns.FacetGrid(),map用法
    df.to_dict()转化为字典数据
    springboot 热部署
    Springboot thymeleaf
    springboot 静态资源
    springboot yaml part2
    Warning: You cannot set a form field before rendering a field associated with the value. ant desgin pro form 表单报错
  • 原文地址:https://www.cnblogs.com/layuechuquwan/p/11352785.html
Copyright © 2011-2022 走看看